質問編集履歴
2
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -73,3 +73,57 @@
|
|
73
73
|
send関数は使わない方がよいのでしょうか??
|
74
74
|
|
75
75
|
分かる方教えてください。
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
[追記]
|
80
|
+
|
81
|
+
strcmp()の方は以下のように新たな関数を作成したら、できました。
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
```C
|
86
|
+
|
87
|
+
int recv_line(int sockfd, unsigned char *dest_buffer) {
|
88
|
+
|
89
|
+
#define EOL "\r\n"
|
90
|
+
|
91
|
+
#define EOL_SIZE 2
|
92
|
+
|
93
|
+
unsigned char *ptr;
|
94
|
+
|
95
|
+
int eol_matched = 0;
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
ptr = dest_buffer;
|
100
|
+
|
101
|
+
while(recv(sockfd, ptr, 1, 0) == 1) { // 1バイトを読み込む。
|
102
|
+
|
103
|
+
if(*ptr == EOL[eol_matched]) {
|
104
|
+
|
105
|
+
eol_matched++;
|
106
|
+
|
107
|
+
if(eol_matched == EOL_SIZE) {
|
108
|
+
|
109
|
+
*(ptr+1-EOL_SIZE) = '\0';
|
110
|
+
|
111
|
+
return strlen(dest_buffer);
|
112
|
+
|
113
|
+
}
|
114
|
+
|
115
|
+
} else {
|
116
|
+
|
117
|
+
eol_matched = 0;
|
118
|
+
|
119
|
+
}
|
120
|
+
|
121
|
+
ptr++;
|
122
|
+
|
123
|
+
}
|
124
|
+
|
125
|
+
return 0;
|
126
|
+
|
127
|
+
}
|
128
|
+
|
129
|
+
```
|
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -60,7 +60,7 @@
|
|
60
60
|
|
61
61
|
telnet www.internic.net 80
|
62
62
|
|
63
|
-
HEAD / HTTP1.0
|
63
|
+
HEAD / HTTP/1.0
|
64
64
|
|
65
65
|
|
66
66
|
|