Hi all!
I already asked this on reddit 
<https://www.reddit.com/r/golang/comments/712epf/help_implementing_custom_protocol_client/>,
 
but I figured might as well ask it here.
Im trying to implement a custom TCP client. This protocol allows request 
from both the client and the server


Scenario 1:

Client -------REQUEST------> Server

Client <-----RESPONSE------- Server


Scenario 2:

Client <------REQUEST-------- Server

Client -------RESPONSE------> Server


Here's 
<https://gist.github.com/anonymous/8246c2ec615fc101f567ce536f5d284a#file-client-go-L88>
 simplified 
form of the client. This approach uses a goroutine to read the *net.Conn, 
*parse 
the string to determine the type, 
and send the string to the appropriate channel for that type. Typical usage 
of this client is as follows

    c := client.New("localhost:8888")
    c.Connect()
    c.Send("message")

On small workloads, it works fine, however calling Send around 100 times a 
second times out. 
I can confirm using wireshark that the server indeed sent a response, 
however it seems like the readLoop wasn't able read it and send it to the 
channel.
I would like to ask if this approach is reasonable. Id like to ask anyone 
out there have implemented a client golang library thats able to both send 
and receive requests from  the server. Basically a bidirectional tcp 
client. I know *nats *is similar to this, however their protocol parsing is 
too complex for me. Any new approach/advise will be nice. Thanks!




-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to