Changeset 57957 in vbox
- Timestamp:
- Sep 29, 2015 10:47:47 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/udp.h
r57955 r57957 154 154 * 155 155 * @returns iprt status code. 156 * @param pszAddress The address to connect to. 157 * @param uPort The port to connect to. 158 * @param pSock Where to store the handle to the established connection. 156 * @param pszAddress The address to connect to. 157 * @param uPort The port to connect to. 158 * @param pDefaultDstAddr A default destination address for sending data 159 * through this socket, can be NULL. 160 * @param pSock Where to store the handle to the established connection. 159 161 */ 160 RTR3DECL(int) RTUdpCreateClientSocket(const char *pszAddress, uint32_t uPort, PRT SOCKET pSock);162 RTR3DECL(int) RTUdpCreateClientSocket(const char *pszAddress, uint32_t uPort, PRTNETADDR pDefaultDstAddr, PRTSOCKET pSock); 161 163 162 164 /** @} */ -
trunk/src/VBox/Runtime/r3/udp.cpp
r57955 r57957 688 688 689 689 690 RTR3DECL(int) RTUdpCreateClientSocket(const char *pszAddress, uint32_t uPort, PRT SOCKET pSock)690 RTR3DECL(int) RTUdpCreateClientSocket(const char *pszAddress, uint32_t uPort, PRTNETADDR pDefaultDstAddr, PRTSOCKET pSock) 691 691 { 692 692 /* … … 715 715 if (RT_SUCCESS(rc)) 716 716 { 717 *pSock = Sock; 718 return VINF_SUCCESS; 717 if (pDefaultDstAddr) 718 rc = rtSocketConnect(Sock, pDefaultDstAddr, 0); 719 if (RT_SUCCESS(rc)) 720 { 721 *pSock = Sock; 722 return VINF_SUCCESS; 723 } 719 724 } 720 725 RTSocketClose(Sock); … … 722 727 return rc; 723 728 } 729 -
trunk/src/VBox/Runtime/testcase/tstRTUdp-1.cpp
r57956 r57957 99 99 int rc; 100 100 RTSOCKET hSocket; 101 RTTESTI_CHECK_RC(rc = RTUdpCreateClientSocket(RT_TEST_UDP_CLIENT_ADDRESS, RT_TEST_UDP_CLIENT_PORT, & hSocket),101 RTTESTI_CHECK_RC(rc = RTUdpCreateClientSocket(RT_TEST_UDP_CLIENT_ADDRESS, RT_TEST_UDP_CLIENT_PORT, &ServerAddress, &hSocket), 102 102 VINF_SUCCESS); 103 103 if (RT_SUCCESS(rc)) … … 107 107 char szBuf[512]; 108 108 RT_ZERO(szBuf); 109 RTTESTI_CHECK_RC_BREAK(RTSocketWrite To(hSocket, "dude!\n", sizeof("dude!\n") - 1, &ServerAddress), VINF_SUCCESS);109 RTTESTI_CHECK_RC_BREAK(RTSocketWrite(hSocket, "dude!\n", sizeof("dude!\n") - 1), VINF_SUCCESS); 110 110 111 111 RTTESTI_CHECK_RC_BREAK(RTSocketRead(hSocket, szBuf, sizeof("hello\n") - 1, NULL), VINF_SUCCESS); … … 113 113 RTTESTI_CHECK_BREAK(strcmp(szBuf, "hello\n") == 0); 114 114 115 RTTESTI_CHECK_RC_BREAK(RTSocketWrite To(hSocket, "byebye\n", sizeof("byebye\n") - 1, &ServerAddress), VINF_SUCCESS);115 RTTESTI_CHECK_RC_BREAK(RTSocketWrite(hSocket, "byebye\n", sizeof("byebye\n") - 1), VINF_SUCCESS); 116 116 RT_ZERO(szBuf); 117 117 RTTESTI_CHECK_RC_BREAK(RTSocketRead(hSocket, szBuf, sizeof("buh bye\n") - 1, NULL), VINF_SUCCESS);
Note:
See TracChangeset
for help on using the changeset viewer.