How to properly respond dynamically to norm request using unicast? #44
-
Hi I'm trying to implement a server using norm that responds to requests. I can see it is possible that two machines can connect to a multicast address, but in the case that we want to do unicast, what is the best way for a server to respond to a machine that is not known beforehand? In other words, Start a receiver at some IP address (A), another ip address (B) sends to this address, and IP address A responds. I seem to only be able to get this working properly if both A and B know each other's IP address beforehand before starting any sessions. I actually managed to get a crude implementation by retrieving the ip address of the sender and then creating a new session pointing to that ip address and replying. Not sure if that is proper or not. It seems off. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
There are normServer.cpp and normClient.cpp examples in the "norm/examples" directory. These can be built using the appropriate Makefile for your system in the "makefiles" directory. For example, for Linux: cd makefiles The server side usage is: normServer [listen [/]][debug ][trace] where the optional field is an IP multicast address. If that is omitted, the normServer acts as a unicast server. The is the port number the server listens for connection requests from clients. In the case of "multicast server" operation, the server broadcasts to connected clients via the configured IP multicast address while each client has unicast feedback connection to the server. In this way the server can act as a sort of multicast "hub" if desired. Since the example app transmits whatever is piped to its STDIN and outputs whatever is received to its STDOUT you can actually demo this concept with the clients transmitting via unicast to the multicast server (hub) that it "echoes" back out via NORM multicast to the clients. Unicast server operation is pretty much what you would expect. The client usage is: normClient [connect /[,]][debug ][trace] I think there may some additional command line options not described here I added. These examples use the "NormSocket" API extension that is defined in the norm/examples/normSocket.h file. The NormSocket API extension is modeled after typical TCP-like socket calls and includes calls like NormListen(), NormConnect(), NormAccept(), etc. This extension is pretty functional and is a work in progress as I have time to work on it. The underlying NormSocket code uses some special NORM API calls to manage UDP socket binding and reuse that enables the NORM code to emulate connected TCP socket operation where multiple clients can connect to a server listening on a single port number, etc. Since the clients are "connected" to the server (and the server can detect when a client disconnects), the server uses NORM's positive acknowledgment mechanism to conduct ACK-based flow control to connected clients. The server/client application code has rules for demo purposes that allows you do things like pipe a file into the STDIN and transmit to the other endpoints, etc. For example: cat | ./normClient connect 192.168.1.1/5001,224.1.2.3 will cause a client to connect to server listening on port 5001 and transmit the contents of to the server (who will output those contents to STDOUT. With a terminal window, the normServer / normClient instances work like simple text chat applications sending text from STDIN to the remote endpoint where its printed to STDOUT upon receipt. Of course this is example code for illustrative purposes and you can do more with your own code. I would encourage to consider using the NormSocket code (and giving me feedback and/or help develop it) or you can use that as an example for achieving what you want. Hopefully this is helpful. Best regards, Brian |
Beta Was this translation helpful? Give feedback.
There are normServer.cpp and normClient.cpp examples in the "norm/examples" directory. These can be built using the appropriate Makefile for your system in the "makefiles" directory. For example, for Linux:
cd makefiles
make normServer normClient
The server side usage is:
normServer [listen [/]][debug ][trace]
where the optional field is an IP multicast address. If that is omitted, the normServer acts as a unicast server. The is the port number the server listens for connection requests from clients. In the case of "multicast server" operation, the server broadcasts to connected clients via the configured IP multicast address while each client has unicast feedback connection to the server…