I am trying to help a U2 VAR migrate their custom-developed socket interface that uses the GCI to a pure BASIC solution using the U2 socket functions. They realize that by doing this their customers will need to license additional U2 seats, but they hate the UV GCI support issue on UNIX as UV must be re-linked. Unfortunately, the initServerSocket() function has a few flaws that stopped this project.
1) The initServerSocket() function precludes using the standard socket behavior of letting the socket sub-system assign any available port number when the port number 0 is specified. The initServerSocket() function translates all port numbers less than 1 to port 40001. This behavior of forcing port 40001 breaks an important standard feature often used when a server process is spawned to provide a cooperative service for another process. As long as the two cooperative processes can agree and communicate the randomly assigned port number, there is no reason to hard-code the port for either process. In fact, when it is possible to have an indeterminate number of these cooperative processes, trying to assign and track which ports are available, raises to the application level something that is otherwise handled at the kernel layer. That is never a good thing. I can not imagine why U2 restricts a valuable server socket feature. This reminds me of a documentation error that made it into code. 2) The other issue with the initServerSocket() is that it does not recognize when another process already has a given port open for listening. The example program below demonstrates this issue. This flaw prevents the application level from randomly assigning the port number and knowing that the port is actually available. Of course, this would not have been an issue if number 1 above let the socket kernel assign random port numbers. This is an ugly flaw as a program could wait forever for a port, never knowing that another process already has the port in use. I am using UV 10.1.11 PE on Windows. I am hoping someone has developed a work-around (other than GCI) or knows when the fix is scheduled. Best regards, Gyle Program SERVER.SOCKET Print "Select a port number that is already in use on the system to test for contention : " Input listenPort If listenPort = "" Then Stop End result = initServerSocket( "", listenPort, 1, listenerSocket ) If result Then function = "initServerSocket()" Gosub DisplaySocketError: Stop End Else Print "initServerSocket(): listening on port " : listenPort End result = getSocketInformation( listenerSocket, -1, socketInformation ) If result Then function = "getSocketInformation()" Gosub DisplaySocketError: Stop End Print "Server socket information" Print "-----------" Print "Status : " : socketInformation<1,1> Print "Host : " : socketInformation<1,2> Print "Port : " : socketInformation<1,3> Print "Secure : " : socketInformation<1,4> Print "Mode : " : socketInformation<1,5> Print "SERVER.SOCKET ready." Gosub CloseListenSocket: Stop CloseListenSocket: * Close the listen socket result = closeSocket( listenerSocket ) If result Then function = "closeSocket()" Gosub DisplaySocketError: Stop End Return DisplaySocketError: internalResult = getSocketErrorMessage( result, errorMessage ) Print function : " returned: " : result Print errorMessage Return End ------- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/