U
User
Hi,
Let's say that I run this raw code. This is on a server side, the
server will wait for client connection request.
Private MyTcpListener As System.Net.Sockets.TcpListener
Private MySocket As Socket
Dim MyPort as int32
MyPort = 1000
Dim ipHostInfo As IPHostEntry = Dns.GetHostByName(Dns.GetHostName()) Dim
MyIPAddress As IPAddress = ipHostInfo.AddressList(0)
Dim localEndPoint As New IPEndPoint(MyIPAddress, MyPort)
MyTcpListener = New Net.Sockets.MyTcpListener(localEndPoint)
MyTcpListener.Start()
[...]
'Looping periodically on MyTcpListener to see if any client try to
' connect
If Not (MyTcpListener.Pending()) Then
Exit Sub
else
MySocket = MyTcpListener.AcceptSocket
End If
For a new connection MySocket will containt information about the new
client information (port, IP).
If I want many clients being able to connect to this server, do I have
to create an array of MySocket? Then any new accepted client would be
indexed (from i=0 to n, n=max connect allowed). That index would be
useful for me.
And I wouldn't have to care anymore with port number? Is that right?
How could I connect a "datareceive event" from any client?
Thanks you very much!
Let's say that I run this raw code. This is on a server side, the
server will wait for client connection request.
Private MyTcpListener As System.Net.Sockets.TcpListener
Private MySocket As Socket
Dim MyPort as int32
MyPort = 1000
Dim ipHostInfo As IPHostEntry = Dns.GetHostByName(Dns.GetHostName()) Dim
MyIPAddress As IPAddress = ipHostInfo.AddressList(0)
Dim localEndPoint As New IPEndPoint(MyIPAddress, MyPort)
MyTcpListener = New Net.Sockets.MyTcpListener(localEndPoint)
MyTcpListener.Start()
[...]
'Looping periodically on MyTcpListener to see if any client try to
' connect
If Not (MyTcpListener.Pending()) Then
Exit Sub
else
MySocket = MyTcpListener.AcceptSocket
End If
For a new connection MySocket will containt information about the new
client information (port, IP).
If I want many clients being able to connect to this server, do I have
to create an array of MySocket? Then any new accepted client would be
indexed (from i=0 to n, n=max connect allowed). That index would be
useful for me.
And I wouldn't have to care anymore with port number? Is that right?
How could I connect a "datareceive event" from any client?
Thanks you very much!