c++ - Multithreded udp-Server vs. Non blocking calls -


first questions here. gave searched haven't found solution answers problem here. i'm using c++ , need write kind of usp chat (server , client) programs interact 1 another. atm works quite well.

i'm using googles protobuf messages.

i've written that:

server has list of users curently logged in list of messages process , distrubute.

one thread handles receiving on socket (i'm using 1 socket). if command var in message login, looks through list , checks combination of port , ip. if not in, chat creates new user entry.

if command logout, server looks user in list , deletes it.

if command message, server looks if user logged in , puts on message list.

the 2nd thread sending. waits till there message in list , cycles through users send messages sockets except sending one.

the server has set options on socket receive ip.

my question is: performat solution? i've read select , poll. it's multiple receiving sockets while have one. know receiving thread may idling time in environment there high frequent message input.

i'm new socket programming think elegant solution. wondering if create thread gets list receiving thread process messages.

edit: how detect time outs? mean have variable in user list increases or set 0. if messages won't come frequently. maybe server based ping message? or maybe flag on message set acknowledged , gets resend.

on user side need first broadcast find server , set port , accordingly answer. how that?

because should run autonomous. meaning client should detect dmthe server, login, sends commands , detect wether still online.

on server side don't know if important. possibly there might memory issue if there many things connected , non logged off. maybe set 1 h timeout let detect idle clients.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -