|
@@ -1,27 +1,32 @@
|
|
|
/**
|
|
|
- * Simple TCP connection check
|
|
|
- * (c) 1993-2008 OSI
|
|
|
- *
|
|
|
- * Proprietary unpublished code
|
|
|
+ * Simple OSInet TCP test client
|
|
|
*
|
|
|
* WARNING: contains various assumptions regarding the use of IPv4
|
|
|
* This is NOT production-quality code, just a quick debug test
|
|
|
+ *
|
|
|
+ * Sample values:
|
|
|
+ * HOST "profile.microscopy-analysis.com"
|
|
|
+ * PORT 8080
|
|
|
+ * @version $Id: netclient.c,v 1.2 2008-08-01 09:00:33 marand Exp $
|
|
|
+ * @copyright (c) 2008 Ouest Systemes Informatiques (OSInet). All rights reserved
|
|
|
*/
|
|
|
+
|
|
|
+#include "features.h"
|
|
|
+#include "string.h"
|
|
|
+#include "stdlib.h"
|
|
|
+#include "unistd.h"
|
|
|
#include "sys/socket.h"
|
|
|
#include "netinet/in.h"
|
|
|
#include "arpa/inet.h"
|
|
|
#include "netdb.h"
|
|
|
#include "stdio.h"
|
|
|
|
|
|
-// HOST "profile.microscopy-analysis.com"
|
|
|
-// PORT 8080
|
|
|
-//
|
|
|
#define MAX_BUF 100
|
|
|
|
|
|
/**
|
|
|
* Dump client socket info for IPv4
|
|
|
*/
|
|
|
-int showServ(struct sockaddr_in *sn)
|
|
|
+void showServ(struct sockaddr_in *sn)
|
|
|
{
|
|
|
printf("IP Dump\n");
|
|
|
printf(" Family [%d]\n", sn->sin_family);
|
|
@@ -61,12 +66,11 @@ char *getServIp(char *name)
|
|
|
*/
|
|
|
int main (int argc, char **argv)
|
|
|
{
|
|
|
- int sockd;
|
|
|
- int count;
|
|
|
+ int sockd;
|
|
|
struct sockaddr_in serv_name;
|
|
|
- char buf[MAX_BUF];
|
|
|
- int status;
|
|
|
- char *ip;
|
|
|
+ char buf[MAX_BUF];
|
|
|
+ int status;
|
|
|
+ char *ip;
|
|
|
|
|
|
if (argc != 3)
|
|
|
{
|
|
@@ -74,7 +78,7 @@ int main (int argc, char **argv)
|
|
|
exit(1);
|
|
|
}
|
|
|
strcpy(buf, argv[1]);
|
|
|
- ip = getServIp(buf); // warning: static result, overwritten by each call
|
|
|
+ ip = getServIp(buf); /* warning: static result, overwritten by each call */
|
|
|
|
|
|
sockd = socket(AF_INET, SOCK_STREAM, 0);
|
|
|
if (sockd == -1)
|
|
@@ -84,7 +88,7 @@ int main (int argc, char **argv)
|
|
|
}
|
|
|
|
|
|
serv_name.sin_family = AF_INET;
|
|
|
- /* fprintf(stderr, "Inet_aton on %s returns %d\n", */ ip, inet_aton(ip, &serv_name.sin_addr);
|
|
|
+ /* fprintf(stderr, "Inet_aton on %s returns %d\n", ip, */ inet_aton(ip, &serv_name.sin_addr);
|
|
|
serv_name.sin_port = htons(atoi(argv[2]));
|
|
|
|
|
|
showServ(&serv_name);
|