Click here to Skip to main content
16,016,623 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello,

I have made myself a piece of code, but it is not working correctly
PERL
$socket->send($sPacket);
($msg) = '';
recv($socket, $msg, 10, 0) or die "recv: $!"; #This line
if($msg != NULL)
{
    recv($socket, $msg2, 5, 0) or die "recv: $!"; #This line
    if($msg2 == 'p4150')
    {
        print "Successfully connected to the server.";
    }
    else
    {
        print "FAILB : $msg2";
    }
}
else
{
    print "FAILA : $msg";
}


It doesn't work because RECV(with flags 0) wants be to have a buffer of at least the size of the receiving packet. The packet has a length of 15 , I want only the first 10 bits and then the next 5 on the second RECV.
Are there any flags I can use to solve this problem, or is there a good alternative (other receiving function/something else)?

Thanks in advance!,
Tim
Posted

1 solution

Maybe you could try as described here[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900