In C++ (I didn't include code because this is more of a protocol understanding matter) I am creating a SOCKS5 server and had a few questions because the client terminates the connection after I send it the approved message. In the RFC it says BND.ADDR and BND.PORT are used for: RFC 1928
o BND.ADDR server bound address
o BND.PORT server bound
port in network octet order`
In the reply to a CONNECT, BND.PORT contains the port number that the
server assigned to connect to the target host, while BND.ADDR
contains the associated IP address.
Here are my questions,
What is BND.PORT and what should I specify for it?.
What does it mean by "server assigned to connect to the target host" Is target host the "Client"?
I've read the RFC front to back like 5 times and I have yet to understand it, can someone go into more detail about the BND.PORT and what it means?
I was sniffing around in Wireshark and I found that BND.PORT was different for each request made. (I am not sure what port to enter because everything I tried resulted in Proxifer (The socks client) says "The server gave an unexpected replay - Connection terminated"
Wireshark connection hex-dump from an actual SOCKS5 server (not mine):
Just to make sure we're on the same page... This is the relationship between client, server and host. Notice that the client and host can't talk to each other directly.
CLIENT <-> SERVER <-> HOST
What does it mean by "server assigned to connect to the target host" Is target host the "Client"?
No. The "host" is the device the client is trying to connect to via the SOCKS5 server. The "client" is on the other side of the SOCKS5 server, furthest away from the host.
What is BND.PORT and what should I specify for it?.
BND.PORT is the source port of packets leaving the SOCKS5 server, bound for a host. You have no control over what port the server chooses. Think about it. Where does a host see packets coming from? It certainly isn't the client. From the perspective of the host, packets are all coming from the server, it doesn't know about the client. Additionally the BND.ADDR is the IP of the server.
What I've said is true under the condition that CONNECT is being used. I have no experience with BIND or UDP ASSOCIATE yet.
Related
I have created the Delphi application with TIdUDPServer. It listens on a specific port. I forwarded this port on the router programmatically, but I want to make sure my server is accessible from the Internet (from the outside).
Is it correct to use TIdUDPClient with the external IP address (I get it from a special website) and send "hello" to my server, which is in the same application?
I mean, what if the router will return this packet back without actually sending it to the Internet when it will see that the target IP of the packet is its own IP address?
I have read that the overhead is low. What does it really mean when compared to HTTP? Does it not use the ip address of the server to which a client tries to connect to? If not, how does a client connect to a server?
Low overhead means that for a given size of messages there is very little extra information sent. It has nothing to do with broker discovery.
E.g. for a HTTP message there us a relatively large amount of HTTP Headers sent before any of the message is transmitted.
The client will connect to the broker via it's IP address. This can either be known in advance, looked up from a host name via DNS or looked up via a TXT record in the DNS for a given domain. You can see examples of broker discovery on the mqtt.org site here
Here is my situation. I have an application (Mirth Connect) running on the same server as SQL Anywhere 11. There is also another server on the same network running SQL Anywhere 11. I need to connect to both of them. They are both using the same SQL Anywhere "Server Name".
I need to use a JDBC connection to connect to either of them at any given moment. I can connect to the local instance just fine.
I tried to set up an ODBC connection to the remote server. When I test the connection it says it is all good. Then when I try to run a query I notice I am connected to the local server. It must be because both SQL Anywhere servers are using the same "Server Name".
How do I force the ODBC connection to connect to the Remote server?
Thank you!
You need to specify the IP address (and port, if not using the default) in the connection string. Your connection string must contain the LINKS parameter, with (at least) the following options:
LINKS=tcpip(HOST=<remote IP address>;PORT=<remote port>;DoBroadcast=None)
If the remote server is using the default port number, 2638, you don't need to specify the port number in the connection string. DoBroadcast=None tells the client library that it should make a direct connection to that host. The default (for version 11 and older) is to broadcast on the network looking for that server name, and whichever server responds first wins. Since there is a server on the local machine, it is very likely to respond first.
For version 12 and up, you can replace the entire LINKS parameter with the new HOST parameter:
HOST=<remote IP address>:<remote port>
which will have the same behaviour as the LINKS parameter above.
P.S. It is recommended that you give each server a unique server name, thus avoiding the need to hard-code the IP address of the host. Not to mention that you must be using some trickery to fool the second server into either (a) thinking its name is unique, or (b) not checking to see if it's unique, which it does by default. If you use unique server names, you don't need this extra stuff.
Disclaimer: I work for Sybase in SQL Anywhere engineering.
I want to use UDP Socket to simply send an audio stream. My problem is that i can't get it working i thought it would be simpler then using TCP IP.
What i did i droped a UDPSocket component on my form and for the server part i used this code
with udpServer do
begin
LocalHost := '127.0.0.1';
LocalPort := '5002';
Open();
Active := True;
end;
For the client application this :
with udpClient do
begin
RemoteHost := '192.0.168.100'; //my local address
RemotePort := '5002';
Open();
Active := True;
end;
The problem is i am not receving anything. What i am doing wrong i don't have any third-party software that can block the connection.
I didn't find any suitable example for using this component any source of inspiration will be greatly appreciated.
You have the server and the client connect on the same IP.
Usually if you set the server application IP address to 0.0.0.0 it will bind to any available IP address on the given port, including 127.0.0.1.
Then the client must connect to one of the bound IPs. Instead, you had the server listening on 127.0.0.1 and the client connect to 192.0.168.100.
Don't be fooled by the "LocalHost" property name. "Local" here just mean you have to set a "local" IP, an IP assigned to the local machine, not a "remote" (of another machine) one, while the client of course will connect to a "remote" IP, that of the server.
127.0.0.1 is a good choice if and only if you want your server to be available only to local application, because that IP scope is limited to the same machine. If you want to make it available outside the machine, you have to bind it to a valid IP.
Whatever issue you have, tools like Wireshark or Microsoft Network Monitor are very useful to understand what's going on.
You are binding the server to 127.0.0.1, so it will only accept clients that connect to 127.0.0.1 specifically. Your client is connecting to 192.0.168.100 (perhaps you meant 192.168.0.100?) instead.
You need to bind the server to the IP(s) that clients are actually connecting to, or else bind it to 0.0.0.0 to accept connections on any local IP.
Even though UDP is connectionless, this same rule applies to both UDP and TCP, as it applies to the lower level IP routing layer that they both share.
first - it's not a question of "how to bind to port of another software".
now, i have a client-server app, based on TCP and i'd like to make it UDP, but i'm missing something..
i have 2 rules (which i put) to this app:
1) the "server" can stay behind router without any port forwarding configuration.
2) the "client" can listen to only one port.
in TCP i do it like this:
1) the server opens initial connection to the client on port X.
2) when the client wants to open communication channel to the server it uses the initial socket to ask the server for a new one.
3) the server creates a new socket and connect to the client on port X.
4) the client accept this new connection on port X, and now the client talk with the server on this new socket.
this way i can have multiple connections on the same port.
in UDP, i have a little problem..
1) the server sends the initial connection dgram to the client on port X.
2) when the client wants to open communication channel to the server it sends request for a new socket to the initial socket's addr.
3) the server receives the message, creates a new udp socket, and use it to send data to the client on port X.
4) the client receives the new dgram, and ....?
basically what i want to happen now is to "accept" this connection. meaning: to create a new UDP socket, to bind it also to port X and receive data only from that specific incoming socket addr (ip,port). but i cannot do that because i can't bind multiple socket to same port.
so what is the way to create multiple udp connections on one port? (in networking way, not just create a ring buffer of dgrams and send to the right socket)
thanks :)
As UDP is connectionless protocol, on step 4 you check the contents of UDP message and decide how to handle it. In other words, the type of message is defined only by it's contents.
However, I have a feeling that your whole design is a bit wrong. It's much more common for the client to be behind firewall (just because there exist more clients, than servers). If you need to put the server behind firewall, you just configure the firewall to allow connections to the set of ports. Even when you have just one more port opened, nothing prevents the client from connecting to the same server port several times in parallel.