I have made a chat client using TCPListener for server and TCPClient for client it works perfectly fine on localhost.

However it is unable to send message over a ad-hoc network. I have tried everything i can think of.

1.Firewalls allow the application to run on both computers.
2.Even disabling firewalls on both computers doesn't work.
3.I have pinged both the computers from each other and the packets reach fine.

Please guys immediate help is required.

Code for the server

TCPListener listen = new TCPListener(IPAddress.any,port);
TCPClient client = listen.AcceptTcpClient();

and then i make networkstream, streamreader and streamwriter from it.

For the client

TCPClient client = new TCPClient("127.0.0.1",port);
NetworkStream stream = client.GetStream();

and then i make streamreader,streamwriter from it.

As i said before this codes works perfectly on localhost but for some reason doesn't work on a ad-hoc network.

I tried, using the IP address of the host it doesn't work, and i don't think its a firewall problem. Is there a tool that could check whether the packet was sent and also if a packet was received.

"netstat -a" will show you all the connetions you currently have. On the host machine it should show it listening.

Are you behind a NAT? Are you using the internal or external addresses?

nop no NAT or router, we are simple establishing a ad-hoc network between two windwos 7 computers directly.

Edited 4 Years Ago by rrr12345

This article has been dead for over six months. Start a new discussion instead.