[SOLVED] socket 1.

$25

File Name: socket_1..zip
File Size: 84.78 KB

5/5 - (1 vote)

1.
a.
b.
c.IO ?
pthreadcreatepthreadcreate
d. IO

fdsetselectselect readfds select
2.:
a.a.out A.c : seteuidneweffectiveuserid
b.Saved SUIDa.croot
3.dup2

: catmain.cgrep main
:
1 pipeRD, WR RD WR
2 dup2WR,1
3 fork,
4 waitpid,
5 FDopenmain.c, 6 dup2FD,0,
7 dup2RD,0

4.sigprocmask ::
1 25 310 415 520 630

:
.a.out
1 21413 ID21413
kill USR1 21413 5
kill USR1 214138
Kill USR1 21413 20:
5.

6.

7.

8.
include stdio.h include stdlib.h include syssocket.h include netinetin.h include string.h include unistd.h

include arpainet.h
define SERVERPORT 5000 define MAXX,Y XY ? X : Y
void prompt
printfYou ;
fflushstdout;
int main int argc, char argv
int len, rc;
int sockfd;
char sendbuf4096;
char recvbuf4096;
struct sockaddrin servaddr; struct timeval timeout; fdset masterset, selectresult; int maxsd;
ifargc!2 exit1; incorrect usage
ifsockfdsocketAFINET, SOCKSTREAM, 0 0 exit2;socket creation error
memsetservaddr, 0, sizeofservaddr; servaddr.sinfamilyAFINET; servaddr.sinporthtonsSERVERPORT;
ifinetptonAFINET, argv1, servaddr.sinaddr0 exit3;ip adress error
ifconnectsockfd, struct sockaddr servaddr, sizeofservaddr 0 exit4;connection error
FDZEROmasterset; FDSETfilenostdin,masterset; FDSETsockfd,masterset; maxsdMAXfilenostdin, sockfd;
Initialize the timeval struct to 3 minutes.timeout.tvsec360;
timeout.tvusec0;
printfConnected to remote host. Start sending messages.n; prompt;
while1
else

closesockfd;
return 0;
rcrecvsockfd, recvbuf, 4096, 0; if rc0 exit9;recv failed
if rc0

printfServer disconnectedn; closesockfd;
exit0;

recvbufrc0;make null terminated string printfrsn, recvbuf;
prompt;
timed out closesockfd; return 0;
QUIZ 1 memcpyselectresult,masterset,sizeofmasterset; rcselectmaxsd1,selectresult,NULL,NULL,NULL;
ifFDISSET0,selectresultQuiz2
getssendbuf;
sendsockfd, sendbuf, strlensendbuf, 0; prompt;

else ifsockfd,selectresultQuiz3
select
int main
.
if connectsockfd, struct sockaddr servaddr, sizeofservaddr0
exit4; pthreadt a, b;
pthreadcreatea, NULL, threadA, NULL; pthreadcreateb, NULL, threadB, NULL;

pthreadjoina, NULL; pthreadjoinb,NULL; closesockfd;
ifn0
exit5;
threadAthreadB
9.Which of the followings are shared among multiple threadsprocesses? : code, register, stack, data, heap, file, address space
a multiple threads:
b multiple processes

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] socket 1.
$25