---
name: "lo_serverthread.h"
section: "3"
platform: "linux"
package: "liblo"
version: "1:0.36-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/lo_serverthread.h"
---

# lo\_serverthread.h(3)

## NAME

lo\_serverthread.h

## SYNOPSIS

### Functions

**lo\_server\_thread** **lo\_server\_thread\_new** (const char \*port, **lo\_err\_handler** err\_h)\
 Create a new server thread to handle incoming OSC messages.  **lo\_server\_thread** **lo\_server\_thread\_new\_multicast** (const char \*group, const char \*port, **lo\_err\_handler** err\_h)\
 Create a new server thread to handle incoming OSC messages, and join a UDP multicast group.  **lo\_server\_thread** **lo\_server\_thread\_new\_multicast\_iface** (const char \*group, const char \*port, const char \*iface, const char \*ip, **lo\_err\_handler** err\_h)\
 Create a new server thread instance, and join a UDP multicast group, optionally specifying which network interface to use. Note that usually only one of iface or ip are specified.  **lo\_server\_thread** **lo\_server\_thread\_new\_with\_proto** (const char \*port, int proto, **lo\_err\_handler** err\_h)\
 Create a new server thread to handle incoming OSC messages, specifying protocol.  **lo\_server\_thread** **lo\_server\_thread\_new\_from\_url** (const char \*url, **lo\_err\_handler** err\_h)\
 Create a new server thread, taking port and the optional multicast group IP from an URL string.  **lo\_server\_thread** **lo\_server\_thread\_new\_from\_config** (**lo\_server\_config** \*config)\
 Create a new server thread, using a configuration struct.  void **lo\_server\_thread\_free** (**lo\_server\_thread** st)\
 Free memory taken by a server thread.  **lo\_method** **lo\_server\_thread\_add\_method** (**lo\_server\_thread** st, const char \*path, const char \*typespec, **lo\_method\_handler** h, const void \*user\_data)\
 Add an OSC method to the specifed server thread.  void **lo\_server\_thread\_del\_method** (**lo\_server\_thread** st, const char \*path, const char \*typespec)\
 Delete an OSC method from the specifed server thread.  int **lo\_server\_thread\_del\_lo\_method** (**lo\_server\_thread** st, **lo\_method** m)\
 Delete an OSC method from the specified server thread.  void **lo\_server\_thread\_set\_callbacks** (**lo\_server\_thread** st, **lo\_server\_thread\_init\_callback** init, **lo\_server\_thread\_cleanup\_callback** cleanup, void \*user\_data)\
 Set an init and/or a cleanup function to the specifed server thread.  int **lo\_server\_thread\_start** (**lo\_server\_thread** st)\
 Start the server thread.  int **lo\_server\_thread\_stop** (**lo\_server\_thread** st)\
 Stop the server thread.  int **lo\_server\_thread\_get\_port** (**lo\_server\_thread** st)\
 Return the port number that the server thread has bound to.  char \* **lo\_server\_thread\_get\_url** (**lo\_server\_thread** st)\
 Return a URL describing the address of the server thread.  **lo\_server** **lo\_server\_thread\_get\_server** (**lo\_server\_thread** st)\
 Return the **lo\_server** for a **lo\_server\_thread**.  int **lo\_server\_thread\_events\_pending** (**lo\_server\_thread** st)\
 Return true if there are scheduled events (eg. from bundles) waiting to be dispatched by the thread.  void **lo\_server\_thread\_pp** (**lo\_server\_thread** st)\
 Pretty-print a **lo\_server\_thread** object.

## Detailed Description

The liblo headerfile declaring thread-related functions.

Definition in file **lo\_serverthread.h**.

## Function Documentation

### lo\_method lo\_server\_thread\_add\_method (lo\_server\_thread st, const char \* path, const char \* typespec, lo\_method\_handler h, const void \* user\_data)

Add an OSC method to the specifed server thread.

**Parameters**

*st* The server thread the method is to be added to. \
 *path* The OSC path to register the method to. If NULL is passed the method will match all paths. \
 *typespec* The typespec the method accepts. Incoming messages with similar typespecs (e.g. ones with numerical types in the same position) will be coerced to the typespec given here. \
 *h* The method handler callback function that will be called it a matching message is received \
 *user\_data* A value that will be passed to the callback function, h, when its invoked matching from this method.

### int lo\_server\_thread\_del\_lo\_method (lo\_server\_thread st, lo\_method m)

Delete an OSC method from the specified server thread.

**Parameters**

*st* The server thread the method is to be removed from. \
 *m* The **lo\_method** identifier returned from lo\_server\_add\_method for the method to delete from the server.

**Returns**

Non-zero if it was not found in the list of methods for the server.

### void lo\_server\_thread\_del\_method (lo\_server\_thread st, const char \* path, const char \* typespec)

Delete an OSC method from the specifed server thread.

**Parameters**

*st* The server thread the method is to be removed from. \
 *path* The OSC path of the method to delete. If NULL is passed the method will match the generic handler. \
 *typespec* The typespec the method accepts.

### int lo\_server\_thread\_events\_pending (lo\_server\_thread st)

Return true if there are scheduled events (eg. from bundles) waiting to be dispatched by the thread.

### void lo\_server\_thread\_free (lo\_server\_thread st)

Free memory taken by a server thread. Frees the memory, and, if currently running will stop the associated thread.

### int lo\_server\_thread\_get\_port (lo\_server\_thread st)

Return the port number that the server thread has bound to.

### lo\_server lo\_server\_thread\_get\_server (lo\_server\_thread st)

Return the **lo\_server** for a **lo\_server\_thread**. This function is useful for passing a thread's **lo\_server** to **lo\_send\_from()**.

### char \* lo\_server\_thread\_get\_url (lo\_server\_thread st)

Return a URL describing the address of the server thread. Return value must be free()'d to reclaim memory.

### lo\_server\_thread lo\_server\_thread\_new (const char \* port, lo\_err\_handler err\_h)

Create a new server thread to handle incoming OSC messages. Server threads take care of the message reception and dispatch by transparently creating a system thread to handle incoming messages. Use this if you do not want to handle the threading yourself.

**Parameters**

*port* If NULL is passed then an unused port will be chosen by the system, its number may be retrieved with **lo\_server\_thread\_get\_port()** so it can be passed to clients. Otherwise a decimal port number, service name or UNIX domain socket path may be passed. \
 *err\_h* A function that will be called in the event of an error being raised. The function prototype is defined in **lo\_types.h**

### lo\_server\_thread lo\_server\_thread\_new\_from\_config (lo\_server\_config \* config)

Create a new server thread, using a configuration struct.

**Parameters**

*config* A pre-initialized config struct. A pointer to it will not be kept.

**Returns**

A new **lo\_server\_thread** instance.

### lo\_server\_thread lo\_server\_thread\_new\_from\_url (const char \* url, lo\_err\_handler err\_h)

Create a new server thread, taking port and the optional multicast group IP from an URL string.

**Parameters**

*url* The URL to specify the server parameters. \
 *err\_h* An error callback function that will be called if there is an error in messge reception or server creation. Pass NULL if you do not want error handling.

**Returns**

A new **lo\_server\_thread** instance.

### lo\_server\_thread lo\_server\_thread\_new\_multicast (const char \* group, const char \* port, lo\_err\_handler err\_h)

Create a new server thread to handle incoming OSC messages, and join a UDP multicast group. Server threads take care of the message reception and dispatch by transparently creating a system thread to handle incoming messages. Use this if you do not want to handle the threading yourself.

**Parameters**

*group* The multicast group to join. See documentation on IP multicast for the acceptable address range; e.g., http://tldp.org/HOWTO/Multicast-HOWTO-2.html \
 *port* If NULL is passed then an unused port will be chosen by the system, its number may be retrieved with **lo\_server\_thread\_get\_port()** so it can be passed to clients. Otherwise a decimal port number, service name or UNIX domain socket path may be passed. \
 *err\_h* A function that will be called in the event of an error being raised. The function prototype is defined in **lo\_types.h**

### lo\_server\_thread lo\_server\_thread\_new\_multicast\_iface (const char \* group, const char \* port, const char \* iface, const char \* ip, lo\_err\_handler err\_h)

Create a new server thread instance, and join a UDP multicast group, optionally specifying which network interface to use. Note that usually only one of iface or ip are specified.

**Parameters**

*group* The multicast group to join. See documentation on IP multicast for the acceptable address range; e.g., http://tldp.org/HOWTO/Multicast-HOWTO-2.html \
 *port* If using UDP then NULL may be passed to find an unused port. Otherwise a decimal port number or service name or may be passed. If using UNIX domain sockets then a socket path should be passed here. \
 *iface* A string specifying the name of a network interface to use, or zero if not specified. \
 *ip* A string specifying the IP address of a network interface to use, or zero if not specified. \
 *err\_h* An error callback function that will be called if there is an error in messge reception or server creation. Pass NULL if you do not want error handling.

### lo\_server\_thread lo\_server\_thread\_new\_with\_proto (const char \* port, int proto, lo\_err\_handler err\_h)

Create a new server thread to handle incoming OSC messages, specifying protocol. Server threads take care of the message reception and dispatch by transparently creating a system thread to handle incoming messages. Use this if you do not want to handle the threading yourself.

**Parameters**

*port* If NULL is passed then an unused port will be chosen by the system, its number may be retrieved with **lo\_server\_thread\_get\_port()** so it can be passed to clients. Otherwise a decimal port number, service name or UNIX domain socket path may be passed. \
 *proto* The protocol to use, should be one of LO\_UDP, LO\_TCP or LO\_UNIX. \
 *err\_h* A function that will be called in the event of an error being raised. The function prototype is defined in **lo\_types.h**

### void lo\_server\_thread\_pp (lo\_server\_thread st)

Pretty-print a **lo\_server\_thread** object.

### void lo\_server\_thread\_set\_callbacks (lo\_server\_thread st, lo\_server\_thread\_init\_callback init, lo\_server\_thread\_cleanup\_callback cleanup, void \* user\_data)

Set an init and/or a cleanup function to the specifed server thread. To have any effect, it must be called before the server thread is started.

**Parameters**

*st* The server thread to which the method is to be added. \
 *init* The init function to be called just after thread start. May be NULL. \
 *cleanup* The cleanup function to be called just before thread exit. May be NULL. \
 *user\_data* A value that will be passed to the callback functions.

### int lo\_server\_thread\_start (lo\_server\_thread st)

Start the server thread.

**Parameters**

*st* the server thread to start.

**Returns**

Less than 0 on failure, 0 on success.

### int lo\_server\_thread\_stop (lo\_server\_thread st)

Stop the server thread.

**Parameters**

*st* the server thread to start.

**Returns**

Less than 0 on failure, 0 on success.

## Author

Generated automatically by Doxygen for liblo from the source code.
