| 1029 | } |
| 1030 | |
| 1031 | U32 KNativeSocketObject::accept(KThread* thread, const KFileDescriptorPtr& fd, U32 address, U32 len, U32 flags) { |
| 1032 | struct sockaddr_in addr = {}; |
| 1033 | socklen_t addrlen = sizeof(struct sockaddr); |
| 1034 | KMemory* memory = thread->memory; |
| 1035 | readSockAddrIn(&addr, memory, address); |
| 1036 | S32 result = (S32)::accept(this->nativeSocket, (struct sockaddr*)&addr, &addrlen); |
| 1037 | LOG_SOCK("native socket: %x listen result=%x", nativeSocket, result); |
| 1038 | |
| 1039 | if (result>=0) { |
| 1040 | std::shared_ptr<KNativeSocketObject> s = std::make_shared<KNativeSocketObject>(this->domain, this->type, this->protocol); |
| 1041 | KFileDescriptorPtr resultFD = KThread::currentThread()->process->allocFileDescriptor(s, K_O_RDWR, 0, -1, 0); |
| 1042 | |
| 1043 | if (flags & FD_CLOEXEC) { |
| 1044 | resultFD->descriptorFlags|=FD_CLOEXEC; |
| 1045 | } |
| 1046 | if (flags & K_O_NONBLOCK) { |
| 1047 | resultFD->kobject->setBlocking(false); |
| 1048 | } |
| 1049 | |
| 1050 | s->nativeSocket = result; |
| 1051 | #ifndef BOXEDWINE_MULTI_THREADED |
| 1052 | setNativeBlocking(result, false); |
| 1053 | #endif |
| 1054 | |
| 1055 | if (address) { |
| 1056 | writeSockAddrIn(&addr, memory, address); |
| 1057 | } |
| 1058 | if (len) { |
| 1059 | memory->writed(len, 16); |
| 1060 | } |
| 1061 | this->error = 0; |
| 1062 | return resultFD->handle; |
| 1063 | } |
| 1064 | std::shared_ptr< KNativeSocketObject> t = std::dynamic_pointer_cast<KNativeSocketObject>(shared_from_this()); |
| 1065 | return handleNativeSocketError(t, false); |
| 1066 | } |
| 1067 | |
| 1068 | U32 KNativeSocketObject::getsockname(KThread* thread, const KFileDescriptorPtr& fd, U32 address, U32 plen) { |
| 1069 | KMemory* memory = thread->memory; |
nothing calls this directly
no test coverage detected