Click here to Skip to main content
15,065,783 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
ok so i have a problem where like that its working(on ipv4 address and local address):
C#
IPAddress ipaLocal = ipAddress;
tlsClient = new TcpListener(1986);

and like that its not working on ipv4 address:
C#
int port = 1986;
IPAddress ipaLocal = ipAddress;
tlsClient = new TcpListener(ipaLocal,port);


its because its not suppose to work with ipv4 address and with only local address?
and another thing is that i made is that you can close your server and relisten to clients without close the app but there is an error where its says: "only usage of each socket address is allowed", i checked in all the code and found nothing that have been left open.
thank for your time and help!!
the code:[C#] chat server - Pastebin.com[^]
its based on a chat that i found on the internet.

What I have tried:

http://www.codeproject.com/Questions/72635/TCPListener-Stay-Connected-or-Connect-on-Demand
Posted
Updated 22-Jun-16 18:36pm

1 solution

only local address:
C#
var tcpListener = new TcpListener(IPAddress.Parse("127.0.0.1"), 1986);
tcpListener.Start();

or working on any IPv4 address:
C#
var tcpListener = new TcpListener(IPAddress.Any, 1986);
tcpListener.Start();
   
Comments
Member 12181103 23-Jun-16 4:20am
   
but then how can i know what is the ip?
like how i set my own ip?
and what about my second problem?
ty for help!

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