Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Any input on socket wrappers?

Status
Not open for further replies.

djjd47130

Programmer
Nov 1, 2010
480
US
As a few of my other posts are mentioning, I'm building an application where many computers across a network can each connect to each other and test bandwidth speeds between each other. It's purpose is to analyze a network (and eventually draw lines on a map) to identify where certain speeds are good/bad. That much is way down the road, but I'm just trying to get the first version done.

Anyway, I'm posting this thread, not necessarily as a specific problem, but rather asking for any input or recommendations, specifically on how to structure the sockets, packets, commands, etc.

I pretty much already have a working version of just the raw sockets, which can currently just connect and log in. Easy enough. I'm just using the TServerSocket and TClientSocket. It's a multi part system. There are two major pieces:

Server - provides single master connection to provide info about other clients on the network which any client can connect to for testing
Client - two pieces:
- Service - two tasks - Runs as a windows service and does all the core testing.
- Connects to master Server for listing of other clients it can connect to
- Connects to other clients to test ping/speed
- (Also allows incoming connections from local applications which need to interact)
- Application - Can run multiple instances, attaches to local Service to send/receive commands

(All my projects are prefixed with JD, and this is NetSpeed, so everything starts with 'JDNS')

I've built wrappers for the sockets:
- TJDNSServerSocket: TComponent
- with TServerSocket
- TJDNSClientSocket: TComponent
- with TClientSocket
- TJDNSSocket: TObject
- with TCustomWinSocket

I'm sure at least one person will mention NOT to use ScktComp but I already have a bunch of stuff pre-built for them.

For example, when the Client connects to the Server, the Client's expected to immediately log in. From the Client component, you would just simply call SendLogin('MyUsername', 'MyPassword'); Then, on the server, the Server component will trigger an event OnLoginRequest(Sender: TObject; Client: TJDNSSocket; const User, Pass: String; var Allow: Bool); Whatever procedure is called for this event will do the actual validation outside the component, then pass 'Allow := True;' to accept it. The server would then send back the result to the client, and the Client will trigger a corresponding event OnLoginReply(Sender: TObject; Client: TJDNSSocket; const Allow: Bool);

Similar deal when sending any command...

Code:
//Server receives command from client - event triggered by server socket
procedure TJDNSServer.SvrCommand(Sender: TObject; Client: TJDNSSocket; const Command: Integer; const Data: String);
begin
  case Command of
    CMD_CLIENT_LIST: begin
      //Send back list of all clients
    end;
    CMD_CLIENT_DETAIL: begin
      //Send back details of requested client
    end;
    CMD_PING_BEGIN: begin
      //Send beginning of ping test
    end;
    CMD_PING_SEND: begin
      //Send single ping packet
    end;
  end;
end;

My goal is to make these 3 classes reusable. The TJDNSSocket can be used in both the Server and the Client for managing basic session level interaction.

Lost yet? Don't feel bad, I'm the one coding this thing and I'm getting lost...

ANY input would be appreciated, small or big, dumb or genius, simple or complex, feasible or far-fetched, whatever it may be.



JD Solutions
 
My only suggestion would be a set of components that almost set up what you're describing. You have a number of services and, once connected, you can request a particular service which might be to stream a chunk of data to test transmission times.

 
I swear I posted something here earlier, what happened to it?

I was explaining that reinventing the wheel is my whole purpose in this project, just to have the experience and knowledge. I didn't make it clear enough that I don't want to use any other third party stuff for this project. Ughh, I explained it quite thoroughly in my last post, but something happened and that post is gone...

My goal is to build Components of my own which can be re-used. These components will wrap the TServerSocket and TClientSocket, along with the TCustomWinSocket, all in the ScktComp unit. I'm building them to handle the login built-in, and then a common packet structure for sending/receiving commands.

The input I was hoping for is tips on how to structure these sockets, not necessarily recommending to completely scrap everything I've done and start over with 3rd party components. I build components primarily, which can simply be dropped into any project. These sockets I'm building will basically wrap the original socket components in delphi and provide a more intuitive interaction, by sending/receiving commands rather then sending/receiving raw data.

JD Solutions
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top