Why can't I establish a TCP/IP connection between my PC and a friend's PC with windows sockets? (Connection Timed Out) - tcp

So, I've been working for about 1 week and I can't establish the connection, I tried in languages like C++ and C# (I'm focused on doing it in C#) but in neither of the 2 worked.
First of all, when making or downloading these programs there is an alert: "Windows Firewall protect" but I press the Accept button. I tried all the IPv4 addresses that appeared when you type "ipconfig" in the command prompt but only with 1 of them I could make connection (which only worked on my own computer) and with the other one it doesn't even let me make the connection. I also tried with the ip that web pages give you (https://www.whatismyip.com, https://www.cual-es-mi-ip.net) but it did not work either.
When making the connection I first start the server with my friend's computer (which also accepts the Windows Firewall) and then with the same ip and port with which my friend started the server (not 127.0.0.1 or 0.0.0.0) but after a while I get the error 10060 or something related to connection timed out (https://learn.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2).
Note: All these programs are "chats".

Related

telnet behaviour remote vs local

Requesting the local machine fails right away:
telnet localhost 65535
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
while it runs forever when requesting google or any other remote machine:
telnet www.google.com 65535
Trying 2a00:1450:4007:812::2004...
I suppose non standard ports should be closed on web servers. If yes, telnet should end up with a "Connection refused" right away as well. right?
Actually, this can be caused by multiple sources. A not so known, but common one:
There are some firewalls allowing you to delay requests to specific ports.
Think about this: Scanning one IP address for all ports only takes a few seconds.
If you delay the response (in case the port is not opended for instance) it will take a potential attacker much longer to scan all ports.
You could argue that the attacker could count anything taking let´s say 5 seconds or longer as timeout, but, there are applications, SMTP servers for instance, that often actually respond only after 20 seconds or so because of this.
May protocols are trying to be attacked and if you generally define that your mailserver will only respond after 20 seconds, that does not really matter to mails in most cases, most attacks will already count this as timeout and won´t even notice that a mailserver is running there whereas the clients get configured for timeouts of 30 seconds or so and they can connect.
Another common thing is that the windows telnet client won´t really post the output until you press any key.

Ethernet Data Traffic hidden from capture

I have a puzzle I am not able to figure out, I would appreciate any help.
I am connected to a remote desktop using windows default remote desktop utility (Windows 8 locally, Windows 7 remotely).
The remote desktop is not in the same sub-network as my own.
Connection is made through default port 3389. Using Wireshark locally I can confirm the TCP connection being established and the data flow.
Running Wireshark in the remote desktop, I don`t see any flow of data between the two computers.
If I send a ICMP ping from the remote desktop to my computer, it works well and I can see it in Wireshark both remotely as well as locally. But if I send the ICMP ping from my computer to the remote desktop, it fails. I see it leaving my computer through Wireshark, but it never reaches the remote desktop (I don`t see it in Wireshark).
I don't think it is a firewall issue (specially since it can't explain why Wireshark won`t capture the port 3389 RPC flow).
Does anyone have any idea of what might be going on?
I found the main issue.
In Wireshark, turns out it is possible to configure the capture interface with a filter.
To change it, go to: Capture->Interfaces
On the interface being used, stop capturing to enable the Options, there it is possible to configure a capture filter.

Connect to my localhost from another computer NOT in the same network

I have a real IP. Or so I think, basically how I tested this is under windows in cmd I pinged my IP address and I got packages back, so that must mean it's real. However when I start my xampp and go to my IP address in the browser I get
Unable to connect
Firefox can't establish a connection to the server
I tried looking up other questions but they didn't help cause all answers I found were suggesting LAN connection. Can you please explain to me any extra steps I need to take or link an answer that does that. Thanks!
The only way to access your localhost from other computers is over a Local Area Network (LAN); whether wired or wireless, there has to be a physical connection between the computers.
Once the computers are connected, you can access your localhost from the browser with the name of the computer on other computers:
http ://your-computer/path/to/files/
It also works on the same computer, so you can test it there.
You can find the name of your computer by going to the "Network" section in Windows Explorer.
EDIT:
If you want to access a localhost from a computer that is on another network, you have to create a web server; more or less what you would be paying for from a hosting company. Here is how you would do it:
http://arstechnica.com/gadgets/2012/11/how-to-set-up-a-safe-and-secure-web-server/

TCP Connect Fails

I have two applications that talk via TCP, both of which run on Windows XP machines. The client is a third-party application for which I have only the executable, no source. The IP address of the server it connects to is set in a text configuration file. The server is an application I am writing.
All netmasks are 255.255.255.0.
In all cases, the client runs on 192.168.142.202.
I am seeing a case where if I run my server on 192.168.142.207, everything works, but if I move my server over to another machine on the same subnet (192.168.142.105), everything does not work fine. Specifically, the connection does not seem to get properly established. I have looked at what's going on in Wireshark and would like to request assistance interpeting what I see.
On the server side, I see the 3-way handshake: SYN, SYN/ACK, ACK. I get no error codes on the return of accept(), and netstat shows the connection as established.
On the client side, the connection does not seem to be established properly. This causes the client to reconnect periodically, and it will also occasionally close all of the not-correctly-connected sockets that get created as a result. When I look at the client side in Wireshark, I most often see a SYN, SYN, SYN pattern, rather that the expected 3-way handshake. Occassionally, the 3-way handshake does appear, but even then, the client doesn't seem to be happy with the connection because it closes it.
I will note that there are actually two TCP connections between the client and server. The other connection (i.e. not the problematic connection I described above) works just fine. The problematic connection has listening port 5004; the good connection has listening port 1234.
I have placed both .txt and .pcap versions of the client and server Wireshark captures at this link: https://skydrive.live.com/redir.aspx?cid=c5beaf58ac752bb0&resid=C5BEAF58AC752BB0!105&parid=root
As far as the physical network setup goes, there is one switch in between the client and server in the case that works, and there are two switches in between the client and server in the case that doesn't work. All ping tests are successful. There are no wireless connections involved; everything is wired.
All firewalls are off.
Does anybody have any thoughts on either what the problem is or what further data I could gather to solve the problem?
Well, it appears this is not a network or network programming problem at all. I've figured out by trial and error that the third-party software that connects to me wants the machine it runs on to have a smaller IP address than the machine my software runs on. This seems completely arbitrary to me, but empirically, this very strongly appears to be the case. Arghhhh............
Thanks to any and all who may have spent time poring over the Wiresharks dumps I provided...

telnet to a port fails: fuzzy on basic network theory

When some network connection isn't working right, one thing in my bag of tricks is to try opening a telnet connection to it. I don't expect to be able to do anything useful with this connection, but knowing if I can or can't connect is helpful in diagnosing the problem.
So today we had a problem where our app server couldn't open the JDBC connection to our database. However, it works fine when the app server is on the same physical box as the database. Aha, I thought, there must be a firewall blocking that port. So I tried to telnet to that port, and couldn't connect. As a control though, I also telnetted to a database on a box we could connect to and that failed as well. So, the situation is, somehow whatever is listening on that port accepts a JDBC connection from JBoss, but rejects a connect from telnet. How does it distinguish these two connections? Different protocol? Password embedded in the connection request?
Sounds like the database is only accepting connections on the local interface. Is your app server configured to connect to the database via its IP or via either localhost or 127.0.0.1?

Resources