MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / sendto

Method sendto

source/kernel/knativesocket.cpp:1539–1570  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1537}
1538
1539U32 KNativeSocketObject::sendto(KThread* thread, const KFileDescriptorPtr& fd, U32 message, U32 length, U32 flags, U32 dest_addr, U32 dest_len) {
1540 KMemory* memory = thread->memory;
1541 U32 nativeFlags = 0;
1542 struct sockaddr_in dest = { 0 };
1543 int len=sizeof(struct sockaddr_in);
1544
1545
1546 if (flags & K_MSG_OOB) {
1547 nativeFlags |= MSG_OOB;
1548 flags &= ~K_MSG_OOB;
1549 }
1550 if (flags & K_MSG_NOSIGNAL) {
1551 flags &= ~K_MSG_NOSIGNAL;
1552 }
1553 if (flags) {
1554 kwarn_fmt("KNativeSocketObject::sendto unsupported flags: %d", flags);
1555 }
1556 if (dest_addr) {
1557 readSockAddrIn(&dest, memory, dest_addr);
1558 }
1559 S8* tmp = new S8[length];
1560 memory->memcpy(tmp, message, length);
1561 U32 result = (U32)::sendto(this->nativeSocket, (char*)tmp, length, nativeFlags, dest_addr ? (struct sockaddr*)&dest : nullptr, dest_addr ? len : 0);
1562 LOG_SOCK("%x native socket: %x sendto dest_addr=%x dest_len=%x result=%x", thread->id, nativeSocket, dest_addr, dest_len, result);
1563 delete[] tmp;
1564 if ((S32)result>=0) {
1565 this->error = 0;
1566 return result;
1567 }
1568 std::shared_ptr< KNativeSocketObject> t = std::dynamic_pointer_cast<KNativeSocketObject>(shared_from_this());
1569 return handleNativeSocketError(t, true);
1570}
1571
1572U32 KNativeSocketObject::recvfrom(KThread* thread, const KFileDescriptorPtr& fd, U32 buffer, U32 length, U32 flags, U32 address, U32 address_len) {
1573 BOXEDWINE_CRITICAL_SECTION_WITH_CONDITION(readingCond);

Callers

nothing calls this directly

Calls 4

kwarn_fmtFunction · 0.85
readSockAddrInFunction · 0.85
handleNativeSocketErrorFunction · 0.85
memcpyMethod · 0.80

Tested by

no test coverage detected