[英]c read udp data from a already used port
我一直在使用給出的代碼示例
如何使用C程序讀取來自端口的UDP數據有效載荷
用於從5000端口讀取udp數據。
但是在我的機器中,該端口已被另一個進程使用,我知道。 我想知道的是一種解決方案,即使從其他進程中使用它,也可以保持c代碼從端口接收數據。
謝謝您的幫助。
不,基本上,您不能打開已經被另一個進程使用的UDP端口,除非綁定到該端口的所有套接字以及要綁定到同一端口的所有套接字都設置了選項SO_REUSEPORT。
如果設置了Whithout SO_REUSEPORT選項,則第二次綁定到使用的端口將失敗,錯誤代碼為EINVAL,請參見bind(2)手冊
EINVAL套接字已綁定到一個地址。
對於選項SO_REUSEPORT,可以在SO中參考此帖子 。
[英]How to read the UDP data payload coming from a port using C program
[英]Checking if UDP port is opened already in C
[英]Bind address already used C udp/tcp
[英]read() from UDP socket drops data and blocks unexpectedly in C
[英]How to read data from COM port with C language
[英]C Failing to Read Data from Serial Port in Linux
[英]How to read data from USB port using C
[英]return from read in connected udp sockets in c
[英]Read data from serial port
[英]print ip address and udp port from c code
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.