Forum Discussion
- stapleshome7New ContributorHi Tanya,
I am having some trouble with the TCP/IP server code published on your website. if I use a random port, It fails on socket.bind. the error says :
Invalid procedure call or argument.
But if I use an already listning port, then it freezes on socket.Accept()
Any suggestions????
address = "127.0.0.1";
port = 3751;
receiveTimeout = 15000;
connectionsQueueLength = 2;
socket = dotNET.System_Net_Sockets.Socket.zctor(
dotNET.System_Net_Sockets.AddressFamily.InterNetwork,
dotNET.System_Net_Sockets.SocketType.Stream,
dotNET.System_Net_Sockets.ProtocolType.Tcp
);
broadcast = dotNET.System_Net.IPAddress.Parse(address);
endpoint = dotNET.System_Net.IPEndPoint.zctor_2(broadcast, port);
socket.Bind(endpoint);
socket.Listen(connectionsQueueLength);
connectedSocket = socket.Accept();
connectedSocket.SetSocketOption_3(
dotNET.System_Net_Sockets.SocketOptionLevel.Socket,
dotNET.System_Net_Sockets.SocketOptionName.ReceiveTimeout,
receiveTimeout);
..................
Is there anything that I'm doing wrong?