Two processes using the same port? [closed] - sockets

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
So I was looking into what port dropbox uses on my computer and tried to see what would happen if i created a new http server on that port. Surprisingly it worked. So both dropbox and my http server were running on the same port, but the incoming requests were routed to the different application depending on the source address.
lsof -i tcp:51311
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
Dropbox 3811 user 18u IPv4 0xdedc291239eb197f 0t0 TCP 172.20.10.2:51311->108.160.163.34:http (ESTABLISHED)
node 3984 user 11u IPv4 0xdedc29123b1494cf 0t0 TCP *:51311 (LISTEN)
I am wondering how this works. I thought the os would refuse the bind my http server since the port was already alloted to dropbox but to my surprise it worked. Anyone thoughts?

TCP sockets match against the 4-tuple (source-ip, source-port, destination-ip, destination-port). As long as all four of them don't clash, you can have port reuse.
As long as your daemon doesn't receive a connection from 108.160.163.34:80 your stack can handle it. If the server 108.160.163.34 is well-behaved it won't let an application initiate a connection to your socket (172.20.10.2:51311) with 80 as source port. (bind() should fail with Address already in use).
If it isn't well behaved, the existing dropbox connection will receive an unexpected packet (wrong sequence number space) and your stack will RST it.

The HTTP port being used by Dropbox is at 108.160.263.34, not your local host.
Port 51311 is being used as one outbound port and one listening port. Not 'two services running on the same port'. Otherwise there would be two LISTENING lines.

Related

Is possible with nc or telnet affect a socket [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I have a conceptual question.
If I have a Java socket (this socket stablish a TCP connection by a channel)
If I run a nc command, the nc command open a tcp connection, then the nc can affect my socket
The same question with telnet, is possible that the telnet affect my socket connection?
Not normally. The operating system will keep those sockets separate. You won't easily affect one socket from another.
If your Java application uses local port 10001 to connect to an HTTPS server on port 443, that socket would be dedicated to that connection between those IPs and ports. IF netcat from the same machine connected to the same server on 443, it wouldn't use the same local ports, and they would not be the same socket.
Now, in unixland at least, open sockets are just file descriptors, and those can be passed between programs. So, for example, your Java application can spawn a new thread and hand the open socket to the thread. But an independent process on the system can't easily just nab data from the open socket.
Of course, these limitations are merely enforced in software, not physical laws, so "anything is possible". But operating systems are going to try to stop this kind of thing from happening.

Port Forward Raspberry Pi's Shared Internet Connection [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
I currently have a setup where I got a raspberry pi connected WIRELESSLY to a router and a WIRED desktop connected to the raspberry pi (via Ethernet) and receiving internet from the pi. On the Desktop I want to run a Minecraft server on port 2000, however, I believe that because of my setup this port can only be seen by the PI alone and any not the router and anything else connected to the router. I currently have the PI ITSELF port-forwarded on the router for port 4300, I just need some way to link the pi's wireless connection of port 192.168.1.55:4300 to the shared Ethernet connection of port 192.168.220.78:2000.
I've looked into messing around with the IPTABLES in Rasbian Linux but I don't fully understand them.
My ultimate goal is to let this server be accessible to anyone outside of my home.
I found the problem, apparently, I needed to accept the incoming connections on the server's computer. So on the same computer as the minecraft server I ran: sudo iptables -A INPUT -p tcp --dport 2000 -j ACCEPT

Redirect port 80 to my home server [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
I installed Ubuntu server 16.04 on one of my computer to setup a web server. I want to install Phabricator to manage a video game project with some friends. I'm trying to configure my router (Home Hub 1000 from Bell) to redirect port 80 to this server. The problem is that it doesn't work at all. I can access to my web page from a computer on my local network with the name of the computer, but not from the outside using my IP address (the one used by my router). I added my server to DMZ and I had set up a port forwarding (Protocol: Both, Internal port: 80, External port: 80). My server use a reserved IP address configured on my router.
Thanks for your help.
Besides of a reserved local ip-address, it is useful to have a static ip-address from your provider(because they might change your ip once and a while). You can find your ip on whatismyip.com
When both port forwarding and DMZ are configured in your router, you can look if there is firewall on your server which blocks the external requests.

How packet are allowed/denied over the network [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I am trying to fully understand the TCP/UDP protocol before starting a network project.
Let's say I have a TCP Server. I understand that if I want someone to communicate with via Internet I need to open my listening port: the router/firewall let it pass and redirect it to me.
A TCP client is connecting to me, there is now a bound socket between the two systems. But how the server can send data to the client if this one have his port blocked:
The port is chosen dynamically, how the firewall/router know that it need to allow the data from my server, is it because I already send something to it and now knows that there is some kind of connection?
If yes, does it mean that for UDP both machines needs to unlock the port?
I don't completely understand how it works but this is what I got so far :
Server is listening on port X
Client try to connect to Server on port X (random port Y generated)
Server can now repond to Client on port Y
Port Y is maintened open thanks to TCP with keep-alive packet.
The firewall/router let it 'open' for some.. seconds ? because there was out-coming packet from his network (waiting for in-coming ?)
And that's how two UDP client can for example communicate :
http://en.wikipedia.org/wiki/UDP_hole_punching
Example with Skype :
http://www.h-online.com/security/features/How-Skype-Co-get-round-firewalls-747197.html
Please correct me if I'm wrong or something seems you not quite well.
Thanks
Edit
A NAT router therefore keeps tables of which internal computer has communicated with which external computer and which ports the two have used.
That's the trick that let the firewall "unlock" our port.

unable to send mail when using 3G, but working normally on WIFI [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am using Hmailserver as a mail server, and it is working normally for mail clients using a standard internet connection (wired or wireless).
But when using a mobile device in 3G mode, suddenly it is not possible to send emails anymore. In the mail client there is a non saying error message (such as unknown error ocurred). Is there any reason for this?
It is quite hard to say; however, e-mail usually travels over port 25 when using SMTP. Likely your 3G provider is blocking outgoing port 25 connections.
You can verify this by using telnet (a Google for "Windows telnet" will provide some Microsoft documentation) to connect to a well-known mail server (these are advertised in DNS MX records). On Windows, I believe the syntax at the command line would be: "telnet <host> 25" (for Google a valid mail-host is alt2.aspmx.l.google.com).
If your provider is blocking port 25 traffic, you will see a connection denied message. Usually ISP's prefer you connect to their SMTP server -- so that they can prevent SPAM from emanating from their network.