Help with socket call in Datablade IDS/UDO9.14X
Posted in 1998
Topics: Networking & sqlhosts Configuration
Hi, we are migrating one function from Illustra to IDS/UDO 9.14x. This function needs to make TCP/IP socket call. It worked fine in Illustra but failed in Informix, complaining memory problem. Here is the code: ==================== code starts ==================== #include "local.h" #include <stdio.h> #include <mi.h> void cybertrans(char *request, char *addr, unsigned short int port, char *reply) { struct sockaddr_in *serv; int sockfd, n; if ( (sockfd = socket(PF_INET, SOCK_STREAM, 0)) < 0) fprintf(stderr, "Socket Open Error Tao0\\n"); serv = (struct sockaddr_in *) mi_alloc(sizeof(struct sockaddr_in)); memset(serv, 0, sizeof(struct sockaddr_in)); (*serv).sin_family = AF_INET; (*serv).sin_addr.s_addr = inet_addr (addr); (*serv).sin_port = htons(port); if (connect(sockfd, (SA) serv, sizeof(struct sockaddr_in)) < 0) fprintf(stderr, "Socket Connetion Error Tao1\\n"); /* form request[] ... */ if (write(sockfd, request, strlen(request)) != strlen(request)) fprintf(stderr, "Socket Write Error Tao2\\n"); if (shutdown(sockfd, 1) < 0) fprintf(stderr, "Socket Shutdown Error Tao3"); if ( (n = read(sockfd, reply, REPLY)) < 0) fprintf(stderr, "Socket Read Error Tao4\\n"); } ============= code ends =========================== What's wrong with the code? Thank you very very much. Tao. -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own