- Timestamp:
- Sep 26, 2022 2:38:59 PM (2 years ago)
- svn:sync-xref-src-repo-rev:
- 153771
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/mangling.h
r96813 r96864 2758 2758 # define RTTraceSetDefaultBuf RT_MANGLER(RTTraceSetDefaultBuf) 2759 2759 # define RTUdpCreateClientSocket RT_MANGLER(RTUdpCreateClientSocket) 2760 # define RTUdpCreateServerSocket RT_MANGLER(RTUdpCreateServerSocket) 2760 2761 # define RTUdpRead RT_MANGLER(RTUdpRead) 2761 2762 # define RTUdpServerCreate RT_MANGLER(RTUdpServerCreate) -
trunk/include/iprt/udp.h
r96407 r96864 175 175 RTR3DECL(int) RTUdpCreateClientSocket(const char *pszAddress, uint32_t uPort, PRTNETADDR pLocalAddr, PRTSOCKET pSock); 176 176 177 /** 178 * Create a data socket acting as a server. 179 * 180 * @returns iprt status code. 181 * @param pszAddress The address to connect to. 182 * @param uPort The port to connect to. 183 * @param pSock Where to store the handle to the established connection. 184 */ 185 RTR3DECL(int) RTUdpCreateServerSocket(const char *pszAddress, uint32_t uPort, PRTSOCKET pSock); 186 177 187 /** @} */ 178 188 RT_C_DECLS_END -
trunk/src/VBox/Runtime/r3/udp.cpp
r96475 r96864 736 736 } 737 737 738 739 RTR3DECL(int) RTUdpCreateServerSocket(const char *pszAddress, uint32_t uPort, PRTSOCKET pSock) 740 { 741 /* 742 * Validate input. 743 */ 744 AssertReturn(uPort > 0, VERR_INVALID_PARAMETER); 745 AssertPtrReturn(pszAddress, VERR_INVALID_POINTER); 746 AssertPtrReturn(pSock, VERR_INVALID_POINTER); 747 748 /* 749 * Resolve the address. 750 */ 751 RTNETADDR LocalAddr; 752 int rc = RTSocketParseInetAddress(pszAddress, uPort, &LocalAddr); 753 if (RT_FAILURE(rc)) 754 return rc; 755 756 /* 757 * Setting up socket. 758 */ 759 RTSOCKET Sock; 760 rc = rtSocketCreate(&Sock, AF_INET, SOCK_DGRAM, IPPROTO_UDP, false /*fInheritable*/); 761 if (RT_SUCCESS(rc)) 762 { 763 /* 764 * Set socket options. 765 */ 766 int fFlag = 1; 767 if (!rtSocketSetOpt(Sock, SOL_SOCKET, SO_REUSEADDR, &fFlag, sizeof(fFlag))) 768 { 769 /* 770 * Bind a name to the socket. 771 */ 772 rc = rtSocketBind(Sock, &LocalAddr); 773 if (RT_SUCCESS(rc)) 774 { 775 *pSock = Sock; 776 return VINF_SUCCESS; 777 } 778 } 779 RTSocketClose(Sock); 780 } 781 return rc; 782 }
Note:
See TracChangeset
for help on using the changeset viewer.