1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

socket data problem

Discussion in 'Networking' started by Poldan, May 10, 2010.

  1. Poldan

    Poldan New Member

    Messages:
    2
    Thanks Received:
    0
    Can anyone help me with some problem? Have FreeBSD 7.2. When print in perl to the socket(SERVER, PF_INET, SOCK_STREAM, getprotobyname('tcp') ) some times have strange problem. For example - i send to strings to the server - "string1\n" and "STRING2\n". But server receives mixed or broken lines. Something like that "stSTRring1ING2". It's happening on heavy traffic. Why this happening and what can i do to to avoid this errors?
     
  2. expl

    expl New Member

    Messages:
    664
    Thanks Received:
    121
    You might want to post full source of your app.
     
  3. Poldan

    Poldan New Member

    Messages:
    2
    Thanks Received:
    0
    server:
    Code:
    ....
    socket(SERVER, PF_INET, SOCK_STREAM, getprotobyname('tcp') ) ;
    setsockopt(SERVER, SOL_SOCKET, SO_REUSEADDR, 1) ;
    bind(SERVER, sockaddr_in($port, inet_aton($interface))) ;
    listen(SERVER,$mconn);
                                                           
    while (1) {
            sleep 1;
            accept(CLIENT,SERVER)
    
    ......
    

    client:
    Code:
    .....
    socket($socket, PF_INET, SOCK_STREAM, $prot);
    connect($socket, $addr);
    fcntl $socket, &F_SETFL, O_NONBLOCK;
    $socket->autoflush(1);
    ......
    
    print $socket $line;