int mySocket;
struct protoent { char *p_name; /* official protocol name */ char **p_aliases; /* alias list */ int p_proto; /* protocol number */ }
Socket not created : Protocol not supported
char * protoName = "udp"; int s; struct protoent * myproto; ... myproto = getprotobyname(protoName); if (NULL == myproto) { sprintf(buf, "Could not get protocol %s",protoName); perror(buf); exit(-1); } if ((s = socket(AF_INET, SOCK_STREAM, myproto->p_proto)) == -1){ perror("Socket not created "); exit(-1); }
write(s,buf,strlen(buf));
rlen = read(s,buf,200); buf[rlen] = NULL;