Click here to Skip to main content
15,112,232 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My problem is Multiple Sockets are not able to receive data from connections to different ports on a server.

This is what I have in code: Please look at comments.
C#
Socket [] sockets=new Socket[10];

for (int socketnumber=0;socketnumber<10;socketnumber++)
{
    for( int i=startport;i<endport;i++)>
   {
       IPEndpoint remote_endpoint; // Some Server
       remote_endpoint.Port = i; //Only Port is different on server
       sockets[socketnumber].Connect(remote_endpoint );
       Thread.Sleep(10);
       sockets[socketnumber].Send(packet1);
       Thread.Sleep(10)
       sockets[socketnumber].Receive(packet2);//I get a crash here up till //socket number ==9. Only socketnumber=9 works i.e the last socket.


    }
}



So why are all connections not able to receive data but able to send data. Why is the computer allowing the last socket to only receive data.

Please get back to me.

Thanks
Jobin Thomas

UPDATE:
Solved by OP himself. Have asked him to post it as an answer.
Posted
Updated 17-Feb-11 19:19pm
v2
Comments
Nish Nishant 17-Feb-11 21:40pm
   
What do you mean it crashes there? Do you mean that it throws an exception? If so, what does it throw? And what does the exception message say?
Sergey Alexandrovich Kryukov 17-Feb-11 21:40pm
   
Hm... interesting. But that's not all. What do you mean crash? It could be anything... where is you exception dump (dump with all stack and all inner exceptions, recursively), if you have exception? And that should be easy, as this is client part. What happens on server (did server process survive all the time)? Where is you correspondent server part? Where is you packet declaration? What defined you application-level protocol (order of send/receive and other assumptions)?

How can you even hope to get any help if you don't share essential facts?

--SA
[no name] 19-Feb-11 15:35pm
   
Thanks. I fixed the issue. was a problem with the the port number I was talking to the same port number over and over again.
Piccadilly Yum Yum 4-Mar-11 9:44am
   
maybe some block in firewall ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900