- This wiki is out of date, use the continuation of this wiki instead
NET Recv
From FenixWiki
(Difference between revisions)
Revision as of 15:03, 14 April 2007 (edit) Sandman (Talk | contribs) ← Previous diff |
Revision as of 15:10, 14 April 2007 (edit) (undo) Sandman (Talk | contribs) m (→Parameters) Next diff → |
||
Line 23: | Line 23: | ||
| '''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. |
|} | |} | ||
- | |||
== Returns == | == Returns == |
Revision as of 15:10, 14 April 2007
Contents |
Definition
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:
msg = NET_GetMessage(conn_c); Repeat say("Incoming(" + conn_c + "): " + msg); msg = NET_GetMessage(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.
Also called NET_GetMessage().
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. |
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. |
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_GetMessage(netid)) !="" ) say("Incoming(" + netid + "): " + message); End End frame; End End