[問題] Socket programming
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
Linux: g++
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
都是一些標準的library
<sys/types.h>, <sys/socket.h>, <netinet/in.h>, <arpa/inet.h>
<unistd.h>, <netdb.h>, <stdio.h>, <stdlib.h>, <string.h>
問題(Question):
我需要把一些基本的HTTP的Request/response給包好
我把TCP包成一個class
把connect, bind, listen...等等的
變成它的method
我另外包了一個HTTP_Response的class
做send, receive, parse 等等
send, receive就透過上面那個TCP class
我也不知道是怎樣了
一樣的一個TCP method,例如說receive_line好了
我在main裡面直接call receive line,沒有問題,想call幾次都可以
但是如果我在HTTP_Request中再做一個method 包了這個receive_line並且call它
第一次可行,第二次可行
第三次就會收不到東西了,TCP recv就會回傳-1
而且一定是第三次
以簡化code做說明
在main中
TCP sock;
sock.connect(...);
sock.receive_line(...); //喜歡收幾次都可以
但是如果我的HTTP_Response裡面有一個method
int HTTP_Response::receive_line(sock, ...){
return sock.receive_line(...);
}
在main中
TCP sock;
HTTP_Request req;
sock.connect(...);
req.receive_line(sock, ...); // 收三次就會壞掉
怎樣看都是一樣的東西啊....orz...
我知道這樣問還是很模糊
想請教一下這有可能是哪方面的問題
謝謝
餵入的資料(Input):
無
預期的正確結果(Expected Output):
無
錯誤結果(Wrong Output):
無
程式碼(Code):(請善用置底文網頁, 記得排版)
很大一包...
補充說明(Supplement):
無multithreading,無multiprocessing
多謝各位,感激不盡
--
追補前過曰剛;強毅果敢曰剛;致果殺敵曰剛;強而能斷曰剛;
自強不息曰剛;政刑明斷曰剛;威強不屈曰剛;強義果敢曰剛。
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 71.206.104.242
※ 編輯: theWANDERER 來自: 71.206.104.242 (10/03 14:28)
※ 編輯: theWANDERER 來自: 71.206.104.242 (10/03 14:29)
※ 編輯: theWANDERER 來自: 71.206.104.242 (10/03 14:30)
→
10/03 14:33, , 1F
10/03 14:33, 1F
→
10/03 14:33, , 2F
10/03 14:33, 2F
→
10/03 14:37, , 3F
10/03 14:37, 3F
→
10/03 14:38, , 4F
10/03 14:38, 4F
→
10/03 14:38, , 5F
10/03 14:38, 5F
→
10/03 14:47, , 6F
10/03 14:47, 6F
→
10/03 14:48, , 7F
10/03 14:48, 7F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章