sub tb_data_lnk_open { my ($link_add); my ($network_addr, $port_addr); my ($remote_host, $remote_port); $link_add = $_[0]; #=========================================================================# # The input $link_add contains the IP address and port in a single # # separated by a - # #=========================================================================# ($remote_host, $remote_port) = split( /-/, $link_add); #=========================================================================# # Create a socket. The socket is openend with TCP properties # #=========================================================================# socket(LINK_HNDL, PF_INET, SOCK_STREAM, getprotobyname('tcp')); #=========================================================================# # Remote address to connect in the network format # #=========================================================================# $network_addr = inet_aton($remote_host) or return 0; $port_addr = sockaddr_in($remote_port, $network_addr); #=========================================================================# # Connect to the server which is already listening # #=========================================================================# connect(LINK_HNDL, $port_addr) or return 1; return 0; }