Hello All

first I apologize for my English, I'm not a native speaker.
I have a question about how golang  reads the sockets in tcp.

Imagine I send , using a conn.Write(buffer), a buffer which has the 
(unpredictable) size from 80 Bytes to 1516.

Now, if I do something like this (after creating "ln"):

for {
>         message := make([]byte, 1516)
>         var err error
>         // accept connection on port
>         conn, _ := ln.Accept()
>         mytimeout := 1000
>         mytimeout, _ = strconv.Atoi(cf.GConfig["TimeOut"])
>         Gtimeout := time.Duration(mytimeout) * time.Millisecond
>         conn.SetReadDeadline(time.Now().Add(Gtimeout))
>        
>         _, err = conn.Read(message)
>         if err != nil {
>             conn.Close()
>             continue
>         }

 *messageinterpreter(message) // just do something with message*

}


 what I am afraid is that , when the client is sending i.e 100 chars using 
conn.Write(100chars) , the conn.Read will not understand the size, and not 
stop until it has read 1516 bytes

What is the expected behavior in such a case? I cannot serialize this 
content (which is binary) because I fear the impact of overhead.


thanks in advance for any comment.

EFM
 




-- 
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