udpOpen()

Opens a connection to a UDP socket.

Synopsis

int udpOpen(string host, unsigned port [, time timeout]);

Parameters

Parameter Description
host Name of the host, to which the function establishes a connection, for example: eiwnt094.
port Port number, for example: 8080.
timeout Timeout for establishing the connection. This parameter is optional. Default is 5 seconds.

Return value

Descriptor of the opened UDP server socket. Use the function getLastError() to test if the function was executed successfully. In case of errors, the function returns -1.

Error

Missing or wrong arguments.

Description

Opens a connection to a UDP socket. Unlike tcpOpen(), the socket is bounded locally to the specified address (= network interface card). Thus, the socket can only send or receive data over this network adapter. If the local address is "localhost" or "127.0.0.1" or the appropriate IPv6 counterpart "[:: 1]", data can be read / written only from / to the local computer. If
host == ""
there is a connection to all local IP addresses (network interface cards). Then, the socket can receive and send data over all connections.

You can open up to 255 connections at the same time.

Example


       main()
       { 
          dyn_errClass err; 
          int open;
          unsigned port; 
          port = 120; 
          open = udpOpen("eiwnt094", port);
          err = getLastError(); 
          DebugN(open);
          DebugN(err);
       }     

Assignment

Communication functions

Availability

CTRL