[erlang-questions] Best way to create a UDP relay server
Morgan Segalis
msegalis@REDACTED
Tue Oct 23 15:01:37 CEST 2012
Hi everyone,
I would like to create a UDP relay server...
I have a session number, and two IP per session.
When IP 1 send something to server, it would directly send it to IP 2 from the same session number.
I have created once a server handling a lot of connection but using gen_server and TCP.
But I don't know how to do the same with gen_udp, since there is no "connection / accept" per say.
What I would like to do is :
- user 1 sends a message to the server, with it's session number.
- if session number does not exist, it creates a gen_server instance, and add the ip to this session
- user 2 sends a message to the server, with it's session number.
- since the session number is the same as user 1, it just adds the ip to the already created instance of the gen_server.
- if user 1 sends a message to the relay server from now, it will be directly sent to user 2 (without having to send the session number again)
- if user 2 sends a message to the relay server from now, it will be directly sent to user 1 (without having to send the session number again)
Is it at least possible, or am I bound to transfer for every message the session number, and look for it in order to send the message to the paired IP ?
Thank you for your help,
Morgan.
More information about the erlang-questions
mailing list