This wiki is out of date, use the continuation of this wiki instead

NET Recv

From FenixWiki

Revision as of 01:36, 1 September 2007 by Sandman (Talk | contribs)
Jump to: navigation, search

Up to Network.DLL Functions



Contents

Definition

INT NET_Recv ( <WORD connection> , [<BYTE includeseperator>] )

Gets the waiting message on a certain connection.

The function will keep returning messages until it returns "", which indicates no more new messages.

Parameters

WORD connection - The connection identifier.
[BYTE includeseparator] - When true, the separator will be added to the message at the end. When false, it won't. Default is true.

Also called NET_GetMessage().

Returns

INT : Network.DLL Errorcode

"" - There was an error or no message.
 !"" - The message (string). It appears this can also be a byte, word or integer. Just make sure the other peer sent it like it was received.

Notes

It is best to put this function in a frameless loop, like so:

msg = NET_Recv(conn_c);
Repeat
    say("Incoming(" + conn_c + "): " + msg);
    msg = NET_Recv(conn_c);
Until(len(msg)<=0)

This way it will still return "" if "" was indeed sent. If you don't need this or you have some other reason, you can change the loop to suit your needs, like:

while(len(msg = NET_Recv(conn_c))>0)
    say("Incoming(" + conn_c + "): " + msg);
End

Example

Program example;
    include "Network.fh";
Private
    int netid;
    string message;
Begin

    NET_Init(0,10,1);
    netid = NET_Connect("www.google.com",80,true);
   
    Loop
        If(NET.Incoming[netid])
            While( (message = NET_Recv(netid)) !="" )
                say("Incoming(" + netid + "): " + message);
            End
        End
        frame;
    End

End
Personal tools