#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/stat.h>
#include "pi-socket.h"
#include "pi-dlp.h"
#include "pi-header.h"
Include dependency graph for connect.c:

Go to the source code of this file.
Functions | |
| int | pilot_connect (const char *port) |
| int pilot_connect | ( | const char * | port | ) |
Definition at line 61 of file connect.c.
References dlp_OpenConduit(), dlp_ReadSysInfo(), pi_accept(), PI_AF_PILOT, pi_bind(), pi_close(), pi_listen(), PI_PF_DLP, PI_SOCK_STREAM, pi_socket(), and sd.
00062 { 00063 int sd = -1, /* Socket, formerly parent/client_socket */ 00064 result; 00065 00066 struct SysInfo sys_info; 00067 00068 fprintf(stderr, "\n"); 00069 fprintf(stderr," DEPRECATED: The application is calling pilot_connect()\n"); 00070 if ((sd = pi_socket(PI_AF_PILOT, 00071 PI_SOCK_STREAM, PI_PF_DLP)) < 0) { 00072 fprintf(stderr, "\n Unable to create socket '%s'\n", port); 00073 return -1; 00074 } 00075 00076 result = pi_bind(sd, port); 00077 00078 if (result < 0) { 00079 if (port == NULL) 00080 fprintf(stderr, " No port specified\n"); 00081 else 00082 fprintf(stderr, " Unable to bind to port: %s\n", port); 00083 00084 fprintf(stderr, " Please use --help for more information\n\n"); 00085 return result; 00086 } 00087 00088 if (isatty(fileno(stdout))) { 00089 printf("\n Listening for incoming connection on %s... ", 00090 port); 00091 fflush(stdout); 00092 } 00093 00094 if (pi_listen(sd, 1) < 0) { 00095 fprintf(stderr, "\n Error listening on %s\n", port); 00096 pi_close(sd); 00097 return -1; 00098 } 00099 00100 sd = pi_accept(sd, 0, 0); 00101 if (sd < 0) { 00102 fprintf(stderr, "\n Error accepting data on %s\n", port); 00103 pi_close(sd); 00104 return -1; 00105 } 00106 00107 if (isatty(fileno(stdout))) { 00108 printf("connected!\n\n"); 00109 } 00110 00111 if (dlp_ReadSysInfo(sd, &sys_info) < 0) { 00112 fprintf(stderr, "\n Error read system info on %s\n", port); 00113 pi_close(sd); 00114 return -1; 00115 } 00116 00117 dlp_OpenConduit(sd); 00118 return sd; 00119 }
Here is the call graph for this function:
