* SysSocket (domain, type, protocol) - Create socket * domain - socket domain * type - socket type * protcol - socket protocol * * On Success - return file descriptor * On Failure - return -1 */
| 1152 | * On Failure - return -1 |
| 1153 | */ |
| 1154 | long SysSocket(regs64_t* r){ |
| 1155 | int domain = SC_ARG0(r); |
| 1156 | int type = SC_ARG1(r); |
| 1157 | int protocol = SC_ARG2(r); |
| 1158 | |
| 1159 | Socket* sock = Socket::CreateSocket(domain, type, protocol); |
| 1160 | |
| 1161 | if(!sock) return -1; |
| 1162 | |
| 1163 | fs_fd_t* fDesc = fs::Open(sock, 0); |
| 1164 | |
| 1165 | if(type & SOCK_NONBLOCK) fDesc->mode |= O_NONBLOCK; |
| 1166 | |
| 1167 | int fd = Scheduler::GetCurrentProcess()->fileDescriptors.get_length(); |
| 1168 | |
| 1169 | Scheduler::GetCurrentProcess()->fileDescriptors.add_back(fDesc); |
| 1170 | |
| 1171 | return fd; |
| 1172 | } |
| 1173 | |
| 1174 | /* |
| 1175 | * SysBind (sockfd, addr, addrlen) - Bind address to socket |
nothing calls this directly
no test coverage detected