; opens a socket, OUT: EAX = socket descriptor (eax=0 failed!)

OpenSocket       PROC 

                 INVOKE  WSAStartup, 0101h, ADDR wsadata
                 .IF eax!=NULL
                     INVOKE  ExitProcess, NULL
                 .ENDIF

                 INVOKE  socket, PF_INET, SOCK_STREAM, 0
                 .IF eax==INVALID_SOCKET
                     xor     eax, eax
                 .ENDIF

                 push    eax
                 mov     sin.sin_family, AF_INET
                 INVOKE  htons, serverLISTENPORT
                 mov     sin.sin_port, ax

                 pop     eax

                 ret
OpenSocket       ENDP

ShutdownSocket   PROC sDESC:DWORD

                 mov     receiveLOCK, FALSE
                 mov     isReliable, FALSE
                 INVOKE  closesocket, sDESC
                 INVOKE  WSACleanup

                 ret
ShutdownSocket   ENDP
