Skip to content

openUDP

Jason Watkins edited this page Apr 3, 2015 · 13 revisions

Opens a new UDP socket, binding the incoming port and storing the outgoing host and port.

Syntax

Language Signature
C struct xpcSocket openUDP(unsigned short port_number, const char *xpIP, unsigned short xpPort)
MATLAB function [socket] = openUDP(port, varargin)
Java XPlaneConnect(int port, String xplaneHost, int xplanePort, int timeout)
Python N/A

Exceptions

Error Code Exception Description
SocketException The incoming port could not be bound
UnknownHostException The specified X-Plane host could not be resolved

Example

C
readfd = openUDP(49055, IP, PORT); //Open socket for receiving
sendfd = openUDP(49077, IP, PORT); //Open socket for sending

// Use sockets

closeUDP(readfd);
closeUDP(sendfd);
MATLAB
Socket = openUDP(49005);

// Use socket

closeUDP(Socket);
Java
try(XPlaneConnect xpc = new XPlaneConnect())
{
    // Use socket
}