Search:
Namespaces
Discussions
.NET v1.1
Feedback
Socket.IO
Messages
Related Types
This message was discovered on
ASPFriends.com 'ngfx-io' list
.
Lasse Johansen
Hello
I have been trying to make a socket listener, but it seems as if I am missing something
Here is my code:
Dim listener As Socket
Dim socketed As Socket
listener = New
Socket
(
AddressFamily
.InterNetwork,
SocketType
.Stream,
ProtocolType
.Tcp) 'makes a server
listener.Bind(New Net.
IPEndPoint
(Net.
Dns
.Resolve("192.168.1.44").AddressList(0), 8889))
Dim RecvBytes(256) As Byte
Dim finish As Boolean
listener.Listen(4)
While True
socketed = listener.Accept()
Dim bytes As Int32 = socketed.Receive(RecvBytes, RecvBytes.Length, 0)
Dim msg As String
msg = System.Text.
ASCIIEncoding
.ASCII.GetString(RecvBytes, 0, bytes)
MsgBox(msg)
Exit While
End While
I know that some of the code do not make any sence(e.g. exit while), but I have been testing. My problem is the line where I Binds. I want to listen on a special port. I get the error that "The requested address is not valid in its context". I presume that it is the Net.
Dns
.Resolve("192.168.1.44") but I have no idea what else to write. If I change 192.168.1.44 to Localhost, no errors occour. How can I skip this argument? I do not need it at all since I only want to listen on a special port - not giving a damn who is connecting.
Thanks in advance for any suggestions
Lasse
Reply to this message...
Dennis West
Here is some links to socket programming include how to program sockets
http://aspalliance.com/dotnetsolutions/GetSolution.aspx?Category=socket
Hope... thiers some help there.
----- Original Message -----
From: Lasse Johansen
To: ngfx-io
Sent: Tuesday, April 23, 2002 11:27 AM
Subject: [ngfx-io]
Socket
.IO
Hello
I have been trying to make a socket listener, but it seems as if I am missing something
Here is my code:
Dim listener As Socket
Dim socketed As Socket
listener = New
Socket
(
AddressFamily
.InterNetwork,
SocketType
.Stream,
ProtocolType
.Tcp) 'makes a server
listener.Bind(New Net.
IPEndPoint
(Net.
Dns
.Resolve("192.168.1.44").AddressList(0), 8889))
Dim RecvBytes(256) As Byte
Dim finish As Boolean
listener.Listen(4)
While True
socketed = listener.Accept()
Dim bytes As Int32 = socketed.Receive(RecvBytes, RecvBytes.Length, 0)
Dim msg As String
msg = System.Text.
ASCIIEncoding
.ASCII.GetString(RecvBytes, 0, bytes)
MsgBox(msg)
Exit While
End While
I know that some of the code do not make any sence(e.g. exit while), but I have been testing. My problem is the line where I Binds. I want to listen on a special port. I get the error that "The requested address is not valid in its context". I presume that it is the Net.
Dns
.Resolve("192.168.1.44") but I have no idea what else to write. If I change 192.168.1.44 to Localhost, no errors occour. How can I skip this argument? I do not need it at all since I only want to listen on a special port - not giving a damn who is connecting.
Thanks in advance for any suggestions
Lasse
| [ngfx-io] member
Click here to reveal e-mail address
= YOUR ID |
http://www.aspfriends.com/aspfriends/ngfx-io.asp
= JOIN/QUIT
Reply to this message...
Joe Fuentes
go to
http://www.planet-source-code.com
<
http://www.planet-source-code.com
>
and look under the dot net category and do a find on socket
there is a nice easy class for you to work with there.
Joe
-----Original Message-----
From: Lasse Johansen [mailto:
Click here to reveal e-mail address
]
Sent: Tuesday, April 23, 2002 2:27 PM
To: ngfx-io
Subject: [ngfx-io]
Socket
.IO
Hello
I have been trying to make a socket listener, but it seems as if I am
missing something
Here is my code:
Dim listener As Socket
Dim socketed As Socket
listener = New
Socket
(
AddressFamily
.InterNetwork,
SocketType
.Stream,
ProtocolType
.Tcp) 'makes a server
listener.Bind(New
Net.
IPEndPoint
(Net.
Dns
.Resolve("192.168.1.44").AddressList(0), 8889))
Dim RecvBytes(256) As Byte
Dim finish As Boolean
listener.Listen(4)
While True
socketed = listener.Accept()
Dim bytes As Int32 = socketed.Receive(RecvBytes, RecvBytes.Length, 0)
Dim msg As String
msg = System.Text.
ASCIIEncoding
.ASCII.GetString(RecvBytes, 0, bytes)
MsgBox(msg)
Exit While
End While
I know that some of the code do not make any sence(e.g. exit while), but I
have been testing. My problem is the line where I Binds. I want to listen on
a special port. I get the error that "The requested address is not valid in
its context". I presume that it is the Net.
Dns
.Resolve("192.168.1.44") but I
have no idea what else to write. If I change 192.168.1.44 to Localhost, no
errors occour. How can I skip this argument? I do not need it at all since I
only want to listen on a special port - not giving a damn who is connecting.
Thanks in advance for any suggestions
Lasse
| [ngfx-io] member
Click here to reveal e-mail address
= YOUR ID |
http://www.aspfriends.com/aspfriends/ngfx-io.asp
= JOIN/QUIT
Reply to this message...
System.Net.Dns
System.Net.IPEndPoint
System.Net.Sockets.AddressFamily
System.Net.Sockets.ProtocolType
System.Net.Sockets.Socket
System.Net.Sockets.SocketType
System.Text.ASCIIEncoding
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com