/* fpont 12/99 */
/* pont.net */
/* tcpClient.c */
#include
#include
#include
#include
#include
#include
#include
int main()
{
int sockfd;
struct sockaddr_in dest;
char buffer[128];
/* create socket */
sockfd = socket(PF_INET, SOCK_STREAM, 0);
/* initialize value in dest */
bzero(&dest, sizeof(dest));
dest.sin_family = PF_INET;
dest.sin_port = htons(8889);
inet_aton("192.168.10.33", &dest.sin_addr);
/* Connecting to server */
connect(sockfd, (struct sockaddr*)&dest, sizeof(dest));
/* Receive message from the server and print to screen */
bzero(buffer, 128);
recv(sockfd, buffer, sizeof(buffer), 0);
printf("%s", buffer);
/* Close connection */
close(sockfd);
return 0;
}
要編釋這個程式,使用指令: gcc sample-client.c -o sample-client
要執行程式可以使用指令: ./sample-client
http://www.linuxhall.org/modules.php?name=News&file=article&sid=79
- Dec 25 Tue 2007 15:55
可透過Socket執行Informix 4GL程式(Client端)
全站熱搜
留言列表
禁止留言