MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / CreateSocket

Method CreateSocket

Kernel/src/net/socket.cpp:8–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6#include <scheduler.h>
7
8Socket* Socket::CreateSocket(int domain, int type, int protocol){
9 if(type & SOCK_NONBLOCK) type &= ~SOCK_NONBLOCK;
10
11 if(domain != UnixDomain && domain != InternetProtocol){
12 Log::Warning("CreateSocket: domain %d is not supported", domain);
13 return nullptr;
14 }
15 if(type != StreamSocket && type != DatagramSocket){
16 Log::Warning("CreateSocket: type %d is not supported", type);
17 return nullptr;
18 }
19 if(protocol){
20 Log::Warning("CreateSocket: protocol is ignored");
21 }
22
23 if(domain == UnixDomain){
24 return new LocalSocket(type, protocol);
25 } else if (domain == InternetProtocol){
26 if(type == DatagramSocket){
27 return new UDPSocket(type, protocol);
28 }
29 }
30
31 return nullptr;
32}
33
34Socket::Socket(int type, int protocol){
35 this->type = type;

Callers

nothing calls this directly

Calls 1

WarningFunction · 0.85

Tested by

no test coverage detected