J
Jason
Hello
I've got some test code that I've found on the web that is a TCP server and
a TCP client. The server sends data to the client on the port i specify. I
know because get the port number through an IPEndPoint. However when I send
the data back to the server, the server receives it on a different port
number then what I specify, and I can't figure out why.
In my server I use this bit code to create the endpoint and socket. I've
got the server machine set to 192.168.1.3 and the client to 192.168.1.2
Any ideas??
Thanks
Jason
IPEndPoint ipep = new IPEndPoint(IPAddress.Any, 5567); // my port #
Socket newsock = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
newsock.Bind(ipep);
newsock.Listen(10);
Console.WriteLine("Waiting for a client...");
Socket client = newsock.Accept();
IPEndPoint newclient = (IPEndPoint)client.RemoteEndPoint;
Console.WriteLine("Connected with {0} at port {1}",newclient.Address,
newclient.Port);
As I said the client recieves the data on port 5567 but when I send it back
to the server the server get it on some odd port number
Client code that sends data back to the server.
IPEndPoint ipep = new IPEndPoint(IPAddress.Parse("192.168.1.3"), 5567);
Socket Toserver = new Socket(AddressFamily.InterNetwork,SocketType.Stream,
ProtocolType.Tcp);
Toserver.Connect(ipep);
sent = sToserver.Send(data, total, dataleft, SocketFlags.None);
I've got some test code that I've found on the web that is a TCP server and
a TCP client. The server sends data to the client on the port i specify. I
know because get the port number through an IPEndPoint. However when I send
the data back to the server, the server receives it on a different port
number then what I specify, and I can't figure out why.
In my server I use this bit code to create the endpoint and socket. I've
got the server machine set to 192.168.1.3 and the client to 192.168.1.2
Any ideas??
Thanks
Jason
IPEndPoint ipep = new IPEndPoint(IPAddress.Any, 5567); // my port #
Socket newsock = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
newsock.Bind(ipep);
newsock.Listen(10);
Console.WriteLine("Waiting for a client...");
Socket client = newsock.Accept();
IPEndPoint newclient = (IPEndPoint)client.RemoteEndPoint;
Console.WriteLine("Connected with {0} at port {1}",newclient.Address,
newclient.Port);
As I said the client recieves the data on port 5567 but when I send it back
to the server the server get it on some odd port number
Client code that sends data back to the server.
IPEndPoint ipep = new IPEndPoint(IPAddress.Parse("192.168.1.3"), 5567);
Socket Toserver = new Socket(AddressFamily.InterNetwork,SocketType.Stream,
ProtocolType.Tcp);
Toserver.Connect(ipep);
sent = sToserver.Send(data, total, dataleft, SocketFlags.None);