-1
我有一個UDP服務器實現,我在哪裏得到分段錯誤recvfrom
調用。recvfrom調用分段錯誤
#define SIZEOF sizeof
#define PKTSIZE 65535
char tmp_buf[PKTSIZE];
struct sockaddr_storage tmp_from;
int tmp_fromlen = 0;
int tmp_bytes;
tmp_bytes = truncate_size_t_to_int(recvfrom(fd, tmp_buf,
SIZEOF(tmp_buf), 0,
(struct sockaddr *) &tmp_from,
(socklen_t *) &tmp_fromlen));
在此之前,綁定和連接都成功。它是一個單線程進程。 這個recvfrom
調用有什麼問題。 我需要爲recvfrom
做SIGALRM
信號處理嗎? truncate_size_t_to_int用於size_t爲int。
請分享一些更多的代碼。 – Haris
什麼是'tmp_buf'? 「SIZEOF」做什麼? –
char tmp_buf [PKTSIZE]; #define SIZEOF sizeof – agnel