---
name: "YOpenConnection"
section: "3"
platform: "linux"
package: "liby-dev"
version: "2.14.5-7"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/YOpenConnection"
---

# YOpenConnection(3)

connect to Y server

## NAME

YOpenConnection - connect to Y server

## SYNTAX

\#include \<Y2/Y.h\>\
 \#include \<Y2/Ylib.h\>

YConnection \*YOpenConnection(\
\
         const char \**start\_arg*,\
\
         const char \**con\_arg*\
 )

## ARGUMENTS

- *start\_arg*

  Specifies the null terminated command to be executed to start the Y server. This command is only used if the Y server does not appear to be currently running. If you do not want the Y server to be started if it is not running, then just pass NULL.

- *con\_arg*

  Specifies the connect argument to connect to the Y server. The format is a null terminated string of the format "\<address\>:\<port\>" where \<address\> specifies the address of the Y server and \<port\> specifies the port number it is polling for incoming connections on. An example connect argument would be "127.0.0.1:9433" which would connect to localhost on port 9433 (standard port number).

## DESCRIPTION

The YOpenConnection opens a new connection to the Y server.

## RETURN VALUE

The YOpenConnection returns a YConnection pointer that serves as the connection to the Y server and that contains all the information about that Y server. It can also return NULL if it failed to start the Y server (as needed or requested) and/or connect to it.

## EXAMPLE

\#include \<stdio.h\>\
 \#include \<Y2/Y.h\>\
 \#include \<Y2/Ylib.h\>

int main(int argc, char \*argv\[\])\
 {\
\
         YConnection \*con = YOpenConnection(\
\
                 "/usr/sbin/starty",\
\
                 "127.0.0.1:9433"\
\
         );\
\
         if(con == NULL)\
\
                 [return(1)](/return/1.md);

        YCloseConnection(con, False);

        return(0);\
 }

## SEE ALSO

[YCloseConnection(3)](/YCloseConnection/3.md) [YShutdownServer(3)](/YShutdownServer/3.md)
