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("",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.

5 Years
Discussion Span
Last Post by rrr12345

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 by rrr12345

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.