TCP server with multiple Clients

Your client will be dispatched in different threads, so they will not intersect. You just need to add something like “DispatchMethod” where your messages will be processed. using System.Text.RegularExpressions; … if (Regex.IsMatch(bufferincmessage, Properties.Settings.Default.REQLogin, RegexOptions.IgnoreCase)) { … } else if (Regex.IsMatch(bufferincmessage, /*some of your command1*/, RegexOptions.IgnoreCase)) { … } else if (Regex.IsMatch(bufferincmessage, /*some of your command1*/, … Read more

Java HttpURLConnection and pooling

Do both os and is need to be flushed and closed for the underlying socket to be reusable? Closing the input stream is sufficient. You can’t flush an input stream, and flushing an output stream before close is redundant. Will connection.disconnect() close the underlying socket (and hence make it unreusable)? It ‘acts as a hint’ … Read more

passing a struct over TCP (SOCK_STREAM) socket in C

You need the following to portably send struct’s over the network: Pack the structure. For gcc and compatible compilers, do this with __attribute__((packed)). Do not use any members other than unsigned integers of fixed size, other packed structures satisfying these requirements, or arrays of any of the former. Signed integers are OK too, unless your … Read more