[問題] socket server 接不到 client 的訊息

看板C_and_CPP (C/C++)作者 (光⊙﹏⊙)時間9年前 (2017/04/28 15:02), 編輯推噓4(402)
留言6則, 3人參與, 最新討論串1/1
開發平台:ubuntu 額外使用的函式庫:無 兩隻程式, socket server and socket client 程式需求: 1.可以同時使用兩個 client 連到 server上面。 2.client 輸入數字傳送給 Server 完成運算並回傳。 遇到的問題: single thread 的狀況之下 程式的運行是沒有問題的 改成 multi thread 之後 socket有正常create 起來 server 可以正常 write message 給 client 但是 client send 給 server 的訊息好像沒有接到 程式: Server:http://ideone.com/rTrAQO 遇到問題的部分在第55行 56行跟57行是debug用的,只要可以印出來我的問題就解決了... Client:http://ideone.com/nreAdd 麻煩各位大大幫小魯解惑了Q_Q ----- Sent from JPTT on my Sony E6653. -- ◢████◢███ ╭═╮ ◢████◤◢███◤ ║˙║ █████ ████ < ˙║ █ ▉█ ████ ║˙║ ◢▇▇████ ╰═╯ ████████ -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 49.216.64.91 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1493362973.A.7D8.html

04/28 16:55, , 1F
可以先把socket_desc印出來看嗎?
04/28 16:55, 1F

04/28 20:25, , 2F
41. 55. 有問題.
04/28 20:25, 2F

04/29 00:21, , 3F
在socket用pthread要join或detech他 傳fd直接硬轉就好別
04/29 00:21, 3F

04/29 00:21, , 4F
用malloc
04/29 00:21, 4F

04/29 00:26, , 5F
*detach, unix network programming和the linux program
04/29 00:26, 5F

04/29 00:26, , 6F
ming interface可以看看
04/29 00:26, 6F
文章代碼(AID): #1P0kaTVO (C_and_CPP)
文章代碼(AID): #1P0kaTVO (C_and_CPP)