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

Method KNativeSocketObject

source/kernel/knativesocket.cpp:367–422  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

365}
366
367KNativeSocketObject::KNativeSocketObject(U32 domain, U32 type, U32 protocol) : KSocketObject(KTYPE_NATIVE_SOCKET, domain, type, protocol),
368 connecting(false),
369 readingCond(std::make_shared<BoxedWineCondition>(B("KNativeSocketObject::readingCond"))),
370 writingCond(std::make_shared<BoxedWineCondition>(B("KNativeSocketObject::writingCond"))) {
371#ifdef WIN32
372 if (!winsock_intialized) {
373 WSADATA wsaData;
374 static_cast<void>(WSAStartup(0x0202, &wsaData));
375 winsock_intialized=1;
376 }
377#endif
378 U32 nativeType = 0;
379 U32 nativeProtocol = 0;
380
381 this->nativeSocket = 0;
382
383 if (type == K_SOCK_STREAM) {
384 nativeType = SOCK_STREAM;
385 } else if (type == K_SOCK_DGRAM) {
386 nativeType = SOCK_DGRAM;
387 } else if (type == K_SOCK_RAW) {
388 nativeType = SOCK_RAW;
389 } else if (type == K_SOCK_RDM) {
390 nativeType = SOCK_RDM;
391 } else if (type == K_SOCK_SEQPACKET) {
392 nativeType = SOCK_SEQPACKET;
393 } else {
394 this->error = K_EPROTOTYPE;
395 return;
396 }
397 if (protocol == 0) {
398 nativeProtocol = IPPROTO_IP ;
399 } else if (protocol == 1) {
400 nativeProtocol = IPPROTO_ICMP;
401 } else if (protocol == 2) {
402 nativeProtocol = IPPROTO_IGMP;
403 } else if (protocol == 6) {
404 nativeProtocol = IPPROTO_TCP;
405 } else if (protocol == 12) {
406 nativeProtocol = IPPROTO_PUP;
407 } else if (protocol == 17) {
408 nativeProtocol = IPPROTO_UDP;
409 } else if (protocol == 22) {
410 nativeProtocol = IPPROTO_IDP;
411 } else if (protocol == 255) {
412 nativeProtocol = IPPROTO_RAW;
413 } else {
414 this->error = -K_EPROTOTYPE;
415 nativeProtocol = IPPROTO_IP;
416 }
417 this->nativeSocket = (S32)socket(AF_INET, nativeType, nativeProtocol);
418 LOG_SOCK("%x native socket: %x open nativeType=%x nativeProtocol=%x", KThread::currentThread()->id, nativeSocket, nativeType, nativeProtocol);
419#ifndef BOXEDWINE_MULTI_THREADED
420 setNativeBlocking(this->nativeSocket, false);
421#endif
422}
423
424KNativeSocketObject::~KNativeSocketObject() {

Callers

nothing calls this directly

Calls 2

BFunction · 0.85
setNativeBlockingFunction · 0.85

Tested by

no test coverage detected