Web Connection
Web Connection w/ a Socket Service
Gravatar is a globally recognized avatar based on your email address. Web Connection w/ a Socket Service
  Rob Corbett
  All
  Jul 17, 2020 @ 06:44pm

I'm successfully using Web Connection to provide REST services for a POS application communicating with about 50 terminals. I'm wanting to add a service for interfacing to a front desk system that only communicates through a socket connection. So I'm trying to use the wwSocket class inside a one of the Server's service functions with code like the following:

DO wwSocket
		
PRIVATE poSock
poSock = CREATE("wwSocket")
poSock.lStripNulls = .T.

PRIVATE pcRequest, pcReply
STORE "" TO pcRequest, pcReply

IF LMSBuild(poLMSConfig, @pcRequest, @lcErrMsg)  && create the request message

   LOCAL lcErrMsg
   lcErrMsg = ""

   * LMSBuild Success, send the request message and get the reply
   pcReply = poSock.SocketSend(@pcRequest, poLMSProc.host, poLMSProc.port, poLMSProc.wait, @lcErrMsg)
			
   IF poSock.nerror = 0

      * SocketSend Success, process the reply
      IF LMSParse(@pcReply, @lcErrMsg)
         ... etc.

The problem is this simply crashes on the SocketSend call with no error message. Is there some inherent problem using wwSocket inside an Application Pool object?

Gravatar is a globally recognized avatar based on your email address. re: Web Connection w/ a Socket Service
  Rick Strahl
  Rob Corbett
  Jul 17, 2020 @ 06:57pm

Can you verify that it works without running inside of IIS and a restricted security context?

wwSocket is pretty rough - at this point I think I would look into using .NET Code to do any socket operations - that's probably much more reliable than the old school raw sockets. That said for simple socket connection and send operation wwSocket should work fine.

My guess on the failure would be that there's probably firewall/connection issues. So I would make sure you can get this to work outside of a Web application to make sure you can actually communicate with the server.

As with all connection based APIs you probably need a TRY/CATCH around this and perhaps you can then get more info.

Gravatar is a globally recognized avatar based on your email address. re: Web Connection w/ a Socket Service
  Rob Corbett
  Rick Strahl
  Jul 17, 2020 @ 07:03pm

Ok, thanks for the advice Rick. I'll try it outside of IIS. The protocol is short request/reply msg pairs, so I thought SocketSend() would be a perfect fit...just wanted to ensure no inherent incompatibility.

© 1996-2024