Application Request Routing (ARR) to save Data in nodes (in Web Farms) - sockets

I Created Socket Client Server Application.
Socket Server in MVC Application and Deployed on IIS port 80.
Socket Server Listener is 88. (Note: Application on IIS port and socket listener is different because port 80 is already in use and in block range and cant use twice at a time.)
The Client Server Communication work Fine.
Problem Statement
Now I want Socket Client Application Send Data/request on ARR port, ARR forward it to Node (in web farm), Node Save the Data/ or Socket Listener respond back.
My ARR Environment is:
ARR Machine (Routing Request)
Node1 (Application (Socket Listener))
Client Machine (Client Application)
How to make it Possible?

Related

Client and Server connection with different port numbers?

I have set up a client and a server using sockets in python where my client sends data to the server, servers performs an operation, then returns some data to the client. Originally both the client and server were to have the same port number (9999). My issue currently is that I have to change the port of the server to 19999, and when I try to run, it does not work. The client is able to send data if its port is also changed to 19999, but it does not work if client is 9999 and server is 19999, which is what I need. New to networking systems so would appreciate any useful links to information or advice.
pic of client (left) and server (right)
Normally, clients will use an ephemeral port for its local port, and connect to the server port. Your client code is attempting to connect to port 9999, which is not the server port, which explains why it is not working. You need to connect to port 19999, since that is the port the server is listening on.
Using an unbound socket causes the client to choose an ephemeral port for its local address when making a connection. If you want the client to bind to a specific port, use bind before you call connect.
# bind locally to 9999
local_addr = (host, 9999)
s.bind(local_addr)
# connect to 19999
remote_addr = (host, 19999)
s.connect(remote_addr)

send data between two server sockets

I have to make an app using C/PHP sockets on linux that sends data from one socket to other socket, like this.
I have server (server_hosted) hosted somewhere with an IP or domain name. It is running web application.
I have another server (unknown_server) running at my home (unknown IP).
Client send some information through web application hosted in server_hosted to another server running at my home (unknown IP).
I need a way to established a connection between server_hosted and unknown_server.
I was able to make connection between both using TCP socket. I made server_hosted as server listen to certain port says 8080 and unknown_server as client, which make open connection to server_hosted.
The problem comes when I have multiple unknown_server at my home. How can I made connection to same port? How many client can TCP/IP support?
Any ides how to make tunnel or connection between server_hosted and unknown_server.
Is possible to do with curl or socket any better ideas?

how listening to a socket works

If a client listens on a socket, at http://socketplaceonnet.com for example, how does it know that there is new content? I assume the server cannot send data directly to the client, as the client could be behind a router, with no port forwarding so a direct connection is not possible. The client could be a mobile phone which changes it's IP address. I understand that for the client to be a listener, the server doesn't need to know the client's IP.
Thank you
A client socket does not listen for incoming connections, it initiates an outgoing connection to the server. The server socket listens for incoming connections.
A server creates a socket, binds the socket to an IP address and port number (for TCP and UDP), and then listens for incoming connections. When a client connects to the server, a new socket is created for communication with the client (TCP only). A polling mechanism is used to determine if any activity has occurred on any of the open sockets.
A client creates a socket and connects to a remote IP address and port number (for TCP and UDP). A polling mechanism can be used (select(), poll(), epoll(), etc) to monitor the socket for information from the server without blocking the thread.
In the case that the client is behind a router which provides NAT (network address translation), the router re-writes the address of the client to match the router's public IP address. When the server responds, the router changes its public IP address back into the client's IP address. The router keeps a table of the active connections that it is translating so that it can map the server's responses to the correct client.
The TCP Iterative server accepts a client's connection, then processes it, completes all requests from the client,
and disconnects. The TCP iteration server can only process one client's request at a time. Only when all the
requests of the client are satisfied, the server can continue the subsequent requests. If one client occupies the
server, other clients can't work, so TCP servers seldom use the iterated server model.

Server/Client using socket programming

Let's say I have a server socket listening on port no 5010. When client tries to connect to this server socket using connect() API, server accepts socket connection in accept() API.
accept() API returns a new socket for server/client connection. Now all data transfer between server and client is done using this newly created socket. Does the data transfer happens on same port 5010. If not, how the ports are chosen when new socket is returned as a result of accept() API ?
The connection between the server and the client socket is identified by the tuple (serverAddress, serverPort, clientAddress, clientPort). The server address and server port always stay the same (obviously). The client allocates a (semi-)random "source" port to avoid collisions even if re-using the same address (e.g. when there are multiple clients on the same machine).

tcp/ip monitor

in eclipse, i have a weblogic server running, and a j2ee application deployed to it.
the application is serving on port 7001.
i want to hook the monitor up to the application, i do not know what ports to use.
i think i know what to put in for the Host Name (localhost:7001), but not sure of what to use for type and Local Port. in the proeferences, what is meant by Local Port.
does it matter if i start the monitor before or after the application is running?
my goal is the watch the traffic as i login, from my local machine via a browser, and surf to other parts of the application.
thanks for any help
if your original url for webservice is say http://abc.xyz:5674/ws/wsdl:linkaction
then do these settings for tcp/ip monitor:
local monitoring port:8888
hostname:abc.xyz
port:5674
type:http
Start it
And change the webservice url to "http://localhost:8888/ws/wsdl:linkaction"
Run your client.java as java application
so your request will go through tcp/ip proxy and you can see the soap messages.
The monitor basically acts as a proxy. The local monitoring port is the port you will send requests to the monitor on. It can be any free port (7002, for example).
The host name, port, and type describe what you want the monitor to proxy to. In your case, it would be localhost, 7001, and HTTP.
Then, you would use your browser to access localhost:7002, and the proxied requests and responses would be displayed in the monitor.
Normal SOAP envelope flows
1. Client ----> SOAP envelope ----> Server:9999
Server:9999 ----> SOAP envelope ---> Client
To intercept SOAP envelope, you can host another server (“TcpMonitorServer”) in between client and server, see new flows :
Client ----> SOAP envelope ----> TcpMonitorServer:8888
TcpMonitorServer:8888 --> SOAP envelope ---> Server:9999
Server:9999 ----> SOAP envelope ---> TcpMonitorServer:8888
TcpMonitorServer:8888 ----> SOAP envelope ---> Client
Source