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

NET Recv

From FenixWiki

(Redirected from Net recv)
Jump to: navigation, search

Up to Network.DLL Functions



Contents

[edit] 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.

[edit] 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().

[edit] 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.

[edit] 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

[edit] 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


Network.DLL Functions
Global NET_Init() • NET_Quit() • NET_Version() • NET_IntVersion() • NET_About() • NET_GetError() • NET_Stat_Buffer() • NET_IntToIP() • NET_IPToInt()
Connections NET_Connect() • NET_Listen() • NET_Disconnect() • NET_DisconnectAll()
Connection NET_Resolve() • NET_Hostname() • NET_IPAddress() • NET_Port() • NET_Separator() • NET_GetSeparator() • NET_GetSeparatorLength()
Transfer NET_Recv() • NET_RecvFile() • NET_RecvGraph() • NET_RecvVar() • NET_Send() • NET_SendFile() • NET_SendGraph() • NET_SendRN() • NET_SendVar()
Personal tools