If there's any folks out there who are interested in developing TCP/IP servers, and would be interested in beta testing some code, we're looking for folks to work with our new server API.
Basically, the idea is that it provides a very high level interface that makes it simple to create a scalable, event-driven, multi-threaded TCP/IP server. You don't need to worry about understanding how TCP works, how to create and manage threads, etc. The API takes care of all of that, and all you need to do is write code that responds to specific events. You could do the same sort of thing previous versions of our libraries, but it required that you implement a lot of "glue" code and have a good understanding of how threading works, synchronization functions, events and so on. With this new version, you generally just need to focus on the program logic, and not the networking stuff.
The code to start a server is pretty simple, it's done with a single function call called InetServerStart. It would look something like this:
Then, to actually do something with the server, you'd put that code in a function called EventHandler (or whatever you want to name it):
In this example, it just echoes back whatever the client has sent to it. Each client session is identified by a socket handle (hSocket), which is what you pass to other functions to do things like and read and write data. The event handler executes in the context of the thread that manages that particular client session, so you can perform blocking network operations and so on without worrying about interfering with other threads.
You can also do things like tell the server to suspend accepting client connections, get status information, enumerate the connected clients, and so on. You can also tell the server to limit the maximum number of clients that can connect, the maximum number of connections per IP address, and throttle the rate at which the server will accept connections (to help mitigate things like DoS attacks).
In any case, if you're interested in testing the API, just send me a PM over the next few days. Thanks!
Basically, the idea is that it provides a very high level interface that makes it simple to create a scalable, event-driven, multi-threaded TCP/IP server. You don't need to worry about understanding how TCP works, how to create and manage threads, etc. The API takes care of all of that, and all you need to do is write code that responds to specific events. You could do the same sort of thing previous versions of our libraries, but it required that you implement a lot of "glue" code and have a good understanding of how threading works, synchronization functions, events and so on. With this new version, you generally just need to focus on the program logic, and not the networking stuff.
The code to start a server is pretty simple, it's done with a single function call called InetServerStart. It would look something like this:
Code:
hServer = InetServerStart(szLocalAddress, _ nLocalPort, _ %INET_BACKLOG, _ nMaxClients, _ %INET_TIMEOUT, _ %INET_PRIORITY_DEFAULT, _ %INET_OPTION_REUSEADDR, _ CODEPTR(EventHandler), _ hDlg, _ 0)
Code:
SUB EventHandler STDCALL (BYVAL hSocket AS LONG, BYVAL nEventId AS LONG, BYVAL dwError AS DWORD, BYVAL dwParam AS DWORD) IF dwError > 0 THEN ' Some error has occurred EXIT SUB END IF SELECT CASE nEventId CASE %INET_EVENT_READ LOCAL nBytesRead AS LONG LOCAL nBytesWritten AS LONG DIM ioBuffer(%BUFFERSIZE) AS LOCAL BYTE nBytesRead = InetRead(hSocket, ioBuffer(0), %BUFFERSIZE) IF nBytesRead > 0 THEN nBytesWritten = InetWrite(hSocket, ioBuffer(0), nBytesRead) END IF END SELECT END SUB
You can also do things like tell the server to suspend accepting client connections, get status information, enumerate the connected clients, and so on. You can also tell the server to limit the maximum number of clients that can connect, the maximum number of connections per IP address, and throttle the rate at which the server will accept connections (to help mitigate things like DoS attacks).
In any case, if you're interested in testing the API, just send me a PM over the next few days. Thanks!
Comment