tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
* tcp client problems on tru64
@ 2000-10-05 14:10 Burt, Andrew D.
  0 siblings, 0 replies; only message in thread
From: Burt, Andrew D. @ 2000-10-05 14:10 UTC (permalink / raw)
  To: tru64-unix-managers

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: multipart/mixed; boundary="------_=_NextPart_000_01C02ED6.118421C8", Size: 2480 bytes --]

This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_000_01C02ED6.118421C8
Content-Type: text/plain;
	charset="iso-8859-1"

Hi - this may not be a Tru64-specific issue, but it is part of an
application I'm running exclusively on a number of Tru64 machines.  This is
a code segment that worked fine yesterday, but today is getting garbage back
from the server.  The server, on reception of the test string, responds with
a 16 byte string ("OK" followed by 14 spaces).  This continues to work fine
when fed via a telnet session to the port, but when this program is run, as
of this morning, it returns garbage.  Is there something obvious in the
coding here that would screw something up?  The only suggestions I've gotten
are that I must be conflicting with something else on the stack.  Again, if
this is not the appropriate forum, I apologize.

Andrew David Burt
(503)654-6300 x5482


------_=_NextPart_000_01C02ED6.118421C8
Content-Type: application/octet-stream;
	name="test6.c"
Content-Disposition: attachment;
	filename="test6.c"

#include <sys/file.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <stdio.h>
#include <errno.h>

#define SA struct sockaddr

char strf[64] = "0004test0000000006test\r\n";
char back[64];
char casthost[64] = "139.126.48.80";
struct hostent *hp;
struct sockaddr_in sin;

main () {
int s, i;

/* stream to server */

if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
perror ("Socket error.\n");
exit (11); 
}

memset (&sin, 0, sizeof(sin));
sin.sin_family=AF_INET;
sin.sin_port=htons(6711);
inet_pton(AF_INET, casthost, &sin.sin_addr);

for (i=0; (connect (s, (struct sockaddr *) &sin, sizeof(sin)) < 0) && (i<7); i++){
if (i==6) {
printf("Unable to connect to server.  Please make sure you are connected to the network or try again later.  \n");
exit (12);
}
}

send (s, strf, strlen(strf), 0);
write(1, strf, strlen(strf));

recv(s, back, 16, 0);
write(1, back, strlen(back));
close(s);

printf("back: \"%s\"\n", back);
printf("out string: %s", strf);

exit(0);
}

/* begin functions */

int inet_pton(int family, const char *strptr, void *addrptr)
{
if (family == AF_INET) {
struct in_addr in_val;
if (inet_aton(strptr, &in_val)) {
memcpy (addrptr, &in_val, sizeof(struct in_addr));
return(1);
}
return(0);
}
errno = EAFNOSUPPORT;
return (-1);
}


------_=_NextPart_000_01C02ED6.118421C8--

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2000-10-05 14:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-10-05 14:10 tcp client problems on tru64 Burt, Andrew D.

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox