Advanced Networking Coding Flashcards

(13 cards)

1
Q

Server Bind and Listen

if (___(___, (struct ___*) &___, sizeof(___)) ___)
DieWithSystemMessage(“bind() failed”);

if (___(___, ___) ___)
DieWithSystemMessage(“listen() failed”);

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Server Socket
___ ___ = ___(argv[1]);

int ___;
if ((___ = ___ (___, ___, ___)) ___)
DieWithSystemMessage(“socket() failed”);

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Server Struct

struct ___ ___;
memset(&___, 0, sizeof(___));
___.___ = ___;
___.___.___ = ___(___);
___.___ = ___(___);

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Server Accept

for (;;) {
int ___ = ___(___, (struct ___ *) NULL, NULL);
if (___ < ___)
DieWithSystemMessage(“accept() failed”);

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Server Recv

while ((___ = ___(___, ___, ___ - ___, ___)) ___) {
___[___] = ‘\0’;
fputs(___, stdout);

if (strstr(\_\_\_, "\r\n") \_\_\_ )
	break;
}
if (\_\_\_ \_\_\_)
	DieWithSystemMessage("recv() failed");
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Server Send & Close

snprintf(___, sizeof(___), “%s”, ___);
ssize_t ___ = ___(___, ___, strlen(___), 0);
if (___ ___)
DieWithSystemMessage(“send() failed”);

close(___);

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Client Socket

___ ___ = ___(argv[2]);

int ___ = ___(___, ___, ___);
if (___ ___)
DieWithSystemMessage(“socket() failed”);

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Client Struct

struct ___ ___;
memset(&___, 0, sizeof(___));
___.___ = ___;

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Client Recv & Close

while ((___ = ___(___, ___, ___ - ___, ___)) ___) {
___[___] = ‘\0’;
fputs(___, stdout);
}
if (___ ___)
DieWithSystemMessage(“recv() failed”);

		fputc('\n', stdout);

close(\_\_\_);
exit(0);
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Client rtnVal

int ___ = ___(___, ___, &___.___.___);
if (___ ___)
DieWithUserMessage(“inet_pton() failed”, “invalid address string”);
else if (___ ___)
DieWithSystemMessage(“inet_pton() failed”);
___.___ = ___(___);

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Client Connect

if (___(___, (struct ___ *) &___, sizeof(___)) ___)
DieWithSystemMessage(“connect() failed”);

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Client Send

size_t echoStringLen = strlen(echoString);

snprintf(___, sizeof(___), “%s\r\n”, echoString);
ssize_t ___ = ___(___, ___, strlen(___), 0);
if (___ < 0)
DieWithSystemMessage(“send() failed”);

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Server Accept with Inet_ntop()

for (;;) {
struct ___ ___;
___ ___ = sizeof()
int ___ = accept(___(struct___*),&___,&___)
if(___ < 0)

inet_ntop(\_\_\_,&\_\_\_.\_\_\_,\_\_\_,sizeof(\_\_\_)), ntohs(\_\_\_.\_\_\_) }
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly