Hey, i am currently creating a client/server chat but for some reason when i go to test it, it keeps saying
Run -time error '10048'
Address in use
Would anyone know how to sort this?
Hello,
Like guys said that port some software already listening and you trying to listen already listened port, here is enought in your program to work not so correct with sockets to get Address in use error, for example when you closing program you allways must close all opened/listened sockets! not matter or happen some error or exception!
If you run your program from VB6 developenent enviroment and then stop program from same enviroment then your program don't close they too & i think you leave then that socket in listening mode (but i am not sure, no vb in PC at the monent).
And here is enought to run one your application instance and if then you run another one you get this error too! Just check your processes with windows Task Manager maybye some program instance still in memory, maybye you need code in your program to prevent to run more then one application instance and when you try to run another server instance just activate first, then you must check which application instance already are.
Another thing like guys said here is big possibility then other software in your PC listenint this port, then you can check it with netstat or with sysinternals utility TCPView, i recommending this utility because then you see which application use which ports and what status of port and you can kill they from that utility too, is very possible then you got some example from internet with some typical service with typical port like HTTP 80 usage and maybye in your PC already started IIS on this port or something else like Apache or Tomcat.
What your chat architecture ? If you want to make TCP based chat you need to write 2 programs:
1 - Server, only server listens sockets (run only one instance of it!);
2 - Client, client only connecting (NOT LISTENING ANY PORT) to server and you can run as many as you designed instances of it! Just if you try to write 1 app with both client and server functionality and you test it on same PC you allways will get this error
If you want to have less problems with your chat just write all in UDP, i remember some time ago done something like UDP Broadcast chat with RTF format support to use in small LAN, for example work or small lan at home in this way i don't needed any server just client whic broadcast in subnet like 255.255.255.255 then just if you send something you receive it too
BTW:
1. HTTP can use 80 UDP port too, not only TCP (check this:
http://www.iana.org/assignments/port-numbers)!
2. Ports can be in 0-65535 range and better to use port in 60000+ range and never at 0-1024 range - this is system reserved port numbers!
Good Luck!