× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



From what you are saying, it looks like you need to send the string
after opening the socket.

The server is expecting you to "log on" before it will start sending you data.

Albert

On Fri, Feb 11, 2011 at 1:37 PM, Versfelt, Charles <CVERSFELT@xxxxxxxxx> wrote:

I'm trying to do socket programming for the first time, the client has sent a server which has been set up by operations, I need to access via socket program to call their APIs.

I'm trying to follow the instructions from this article
http://systeminetwork.com/article/introduction-tcpip-programming
And also referring to sample programs.

And using the /copy socket_h

My program is hanging up on the Reply.  It sits there and hangs.

Ops has set up the new server in WRKSRVTBLE as:
 Service                                  Port  Protocol
E0007825019-1                            1200  tcp

The IP address of the new server is in the Host Table entries as E0007825019-01.

Getting the IP address works.

 p_hostent = gethostbyname('E0007825019-01');
 if (p_hostent = *NULL);
   @preturn = 'CPCON01';
   @prtnmsg = 'Host lookup failed. ';
   joblog('Host lookup failed.');
   return;
 else;
   addr = h_addr;
 endif;


Getting the port works.

 p_servent = getservbyname('E0007825019-1': 'tcp');
 if (p_servent <> *NULL);
    port = s_port;
 else;
    port = 1200;
 endif;

Creating the socket works

 s = socket(AF_INET: SOCK_STREAM: IPPROTO_TCP);
 If (s = -1);
   @preturn = 'CPCON02';
   @prtnmsg = 'Socket failed.     ';
   joblog('Socket failed!');
   return;
 endif;

I connect to the server

 connto = *ALLx'00';
 connto.sin_family = AF_INET;
 connto.sin_addr = addr;
 connto.sin_port = port;


 if ( connect(s: %addr(connto): %size(connto)) = -1 );
  callp close(s);
  @preturn = 'CPCON03';
  @prtnmsg = 'Connect failed.    ';
  joblog('Connect failed!');
  return;
 endif;

Just to check the value, at one point I put this value into a variable:
 connect(s: %addr(connto): %size(connto)
The value is 0.
It's certainly not -1, the error.

The program sits and hangs on the if statement:

 if ( GetReply(s) <> 220 );
   @preturn = 'CPCON04';
   @prtnmsg = 'Server Not Ready   ';
   callp close(s);
   joblog('Not ready for SMTP requests.');
   return;
 endif;

Any help I get will be greatly appriciated... If I need to provide more information please let me know.
I don't see anything in the job log pointing me to what's happening.

ALSO, by the way... Not sure if this has anything to do with my problem...
Is it unusual that, I connect using these commands,
Then the first thing the vendor wants me to do in their specs is to send them a CONNECT command?

Or is what they're requesting somehow supposed to be part of my connect?

They want me to connect by sending them a string like this:
'0000000022CONNECT|CLIENTTYPE|20|CLIENTID|222|'

I took that to mean, that once I'm connected (after my if statement) the next thing I do is this:

SendAscii(s: '0000000022CONNECT|CLIENTTYPE|20|CLIENTID|222|');

Does it make sense that I connect (to the server via socket) and then send them their bar-delimited connect command?  It's like I'm connecting to connect...

Charlie











--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.