Download File
Download File Download File
Subject: NETWORK PROGRAMMING LAB Year : 2010 Class : IV B-Tech C.S.E Semester: First /*udp_strrev_clnt.c */ #include /* for exit() */ #include #include #include #include #include #include #include #include /* memset() */ #include /* select() */ #define REMOTE_SERVER_PORT 1500 #define MAX_MSG 100 #define SOCKET_ERROR -1 int isReadable(int sd,int * error,int timeOut) { // milliseconds fd_set socketReadSet; FD_ZERO(&socketReadSet); FD_SET(sd,&socketReadSet); struct timeval tv; if (timeOut) { tv.tv_sec = timeOut / 1000; tv.tv_usec = (timeOut % 1000) * 1000; } else { tv.tv_sec = 0; tv.tv_usec = 0; } // if if (select(sd+1,&socketReadSet,0,0,&tv) == SOCKET_ERROR) { *error = 1; return 0; } // if NP Lab Manual , RNEC page: 44
*error = 0; return FD_ISSET(sd,&socketReadSet) != 0; } /* isReadable */ int main(int argc, char *argv[]) { int sd, rc, i, n, echoLen, flags, error, timeOut; struct sockaddr_in cliAddr, remoteServAddr, echoServAddr; struct hostent *h; char msg[MAX_MSG]; /* check command line args */ if(argch_name, inet_ntoa(*(struct in_addr *)h->h_addr_list[0])); remoteServAddr.sin_family = h->h_addrtype; memcpy((char *) &remoteServAddr.sin_addr.s_addr,h->h_addr_list[0], h- >h_length); remoteServAddr.sin_port = htons(REMOTE_SERVER_PORT); /* socket creation */ sd = socket(AF_INET,SOCK_DGRAM,0); if(sd
- Page 1 and 2: IV YEAR B.Tech Network Programming
- Page 3 and 4: o after call to fork o after both c
- Page 5 and 6: WEEK 1: Aim: Implement the pipe usi
- Page 7 and 8: Subject: NETWORK PROGRAMMING LAB Ye
- Page 9 and 10: Output: [student@localhost ~]$ vi p
- Page 11 and 12: Output: [student@localhost ~/khan]$
- Page 13 and 14: } fclose(f); //closing file //creat
- Page 15 and 16: Subject: NETWORK PROGRAMMING LAB Ye
- Page 17 and 18: Output: [student@localhost ~]$ cc m
- Page 19 and 20: main() { int shmid; int semid; key_
- Page 21 and 22: } for (i = 0; i < CHILD_INCREMENT_C
- Page 23 and 24: if (*parent_shm == (CHILD_INCREMENT
- Page 25 and 26: Subject: NETWORK PROGRAMMING LAB Ye
- Page 27 and 28: Output: [student@localhost ~]$ cc t
- Page 29 and 30: Output: [student@localhost ~]$ ./ t
- Page 31 and 32: } bzero(&servaddr, sizeof(servaddr)
- Page 33 and 34: Subject: NETWORK PROGRAMMING LAB Ye
- Page 35 and 36: Subject: NETWORK PROGRAMMING LAB Ye
- Page 37 and 38: Output: [student@localhost ~]$ cc t
- Page 39 and 40: Output: [student@localhost ~]$ cc t
- Page 41 and 42: servAddr.sin_addr.s_addr = htonl(IN
- Page 43: Output: [student@localhost ~]$ cc u
- Page 47 and 48: if(n
- Page 49 and 50: Subject: NETWORK PROGRAMMING LAB Ye
- Page 51 and 52: printf("%s: from %s:UDP%u : %s \n"
- Page 53 and 54: Subject: NETWORK PROGRAMMING LAB Ye
- Page 55 and 56: cliAddr.sin_family = AF_INET; cliAd
- Page 57 and 58: Output: [student@localhost ~]$ cc u
- Page 59 and 60: if(rc
- Page 61 and 62: Output: [student@localhost ~]$ cc u
- Page 63 and 64: if (select(sd+1,&socketReadSet,0,0,
- Page 65 and 66: } (struct sockaddr *) &echoServAddr
*error = 0;<br />
return FD_ISSET(sd,&socketReadSet) != 0;<br />
} /* isReadable */<br />
int main(int argc, char *argv[])<br />
{<br />
int sd, rc, i, n, echoLen, flags, error, timeOut;<br />
struct sockaddr_in cliAddr, remoteServAddr, echoServAddr;<br />
struct hostent *h;<br />
char msg[MAX_MSG];<br />
/* check command line args */<br />
if(argch_name,<br />
inet_ntoa(*(struct in_addr *)h->h_addr_list[0]));<br />
remoteServAddr.sin_family = h->h_addrtype;<br />
memcpy((char *) &remoteServAddr.sin_addr.s_addr,h->h_addr_list[0], h-<br />
>h_length);<br />
remoteServAddr.sin_port = htons(REMOTE_SERVER_PORT);<br />
/* socket creation */<br />
sd = socket(AF_INET,SOCK_DGRAM,0);<br />
if(sd