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

NET Recv

From FenixWiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 23:36, 15 April 2007 (edit)
Sandman (Talk | contribs)
m (Changed some NET_GetMessage()'s to NET_Recv()'s)
← Previous diff
Revision as of 21:46, 24 July 2007 (edit) (undo)
Sandman (Talk | contribs)

Next diff →
Line 1: Line 1:
[[Category:functions]] [[Category:functions]]
[[Category:networkdllfunctions]] [[Category:networkdllfunctions]]
 +
 +[[networkdllfunctions|'''Up to Network.DLL Functions''']]
 +----
 +
==Definition== ==Definition==
-'''INT''' NET_Recv ( '''WORD''' connection , ['''BYTE''' includeseperator] )+'''INT''' NET_Recv ( <'''WORD''' connection> , [<'''BYTE''' includeseperator>] )
-Gets the waiting message on a connection. The function will keep returning messages until it returns "", which indicates no more new messages. So it is best to put this function in a frameless loop, like so:+Gets the waiting message on a certain connection.
-<pre>+
-msg = NET_Recv(conn_c);+
-Repeat+
- say("Incoming(" + conn_c + "): " + msg);+
- msg = NET_Recv(conn_c);+
-Until(len(msg)<=0)+
-</pre>+
-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.<br />+
-Also called NET_GetMessage().+
 +The function will keep returning messages until it returns "", which indicates no more new messages.
== Parameters == == Parameters ==
- 
{| {|
-| '''WORD''' connection || The connection identifier.+| '''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.+| ['''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 == == Returns ==
- 
'''INT''' : [[NET_ERRORCODES|Network.DLL Errorcode]] '''INT''' : [[NET_ERRORCODES|Network.DLL Errorcode]]
{| {|
-| "" || There was an error or no message.+| "" || - 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.+| !"" || - 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:
 +<pre>
 +msg = NET_Recv(conn_c);
 +Repeat
 + say("Incoming(" + conn_c + "): " + msg);
 + msg = NET_Recv(conn_c);
 +Until(len(msg)<=0)
 +</pre>
 +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:
 +<pre>
 +while(len(msg = NET_Recv(conn_c))>0)
 + say("Incoming(" + conn_c + "): " + msg);
 +End
 +</pre>
== Example == == Example ==
- 
<pre> <pre>
Program example; Program example;

Revision as of 21:46, 24 July 2007

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