开发者

Winsock connection test

开发者 https://www.devze.com 2023-01-26 08:42 出处:网络
How do you test to see if your program is working and able to connect with server? I tried stackoverflow server\'s ip through port 40 and it fails after a min at connect().

How do you test to see if your program is working and able to connect with server? I tried stackoverflow server's ip through port 40 and it fails after a min at connect().

test.exe 64.34.119.12 echo 40

P开发者_高级运维rogram arguments take a syntax: <Server IP> <Echo Word> [<Echo Port>]

Also, can you test without having to connect to internet?


You should be able to connect to your own echo server on 127.0.0.1:7 if it is running, or get a 'connection refused' (ECONN) if it isn't running. Either would show that your code is OK actually.


As for testing without having to connect to the internet...

I'd download netcat for windows.
NetCat download

Extract the tool, and run:

nc.exe -v -l -p [port]

If you do that, it opens up a "server" and you can connect to it using your application; just point the IP address to 127.0.0.1!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号