From owner-freebsd-hackers@FreeBSD.ORG Tue May 31 07:57:42 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 34F0416A41C for ; Tue, 31 May 2005 07:57:42 +0000 (GMT) (envelope-from shiner_chen@yahoo.com.cn) Received: from web15501.mail.cnb.yahoo.com (web15501.mail.cnb.yahoo.com [202.165.102.30]) by mx1.FreeBSD.org (Postfix) with SMTP id 5053943D55 for ; Tue, 31 May 2005 07:57:40 +0000 (GMT) (envelope-from shiner_chen@yahoo.com.cn) Received: (qmail 38576 invoked by uid 60001); 31 May 2005 07:57:39 -0000 Message-ID: <20050531075739.38574.qmail@web15501.mail.cnb.yahoo.com> Received: from [61.187.16.2] by web15501.mail.cnb.yahoo.com via HTTP; Tue, 31 May 2005 15:57:39 CST Date: Tue, 31 May 2005 15:57:39 +0800 (CST) From: shiner chen To: freebsd-hackers@freebsd.org MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="0-633563741-1117526259=:38258" Content-Transfer-Encoding: 8bit X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: the error connection of socket in kernel(new) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 May 2005 07:57:42 -0000 --0-633563741-1117526259=:38258 Content-Type: text/plain; charset=gb2312 Content-Transfer-Encoding: 8bit In order to test the process of connection of socket in kernel ,I wrote a kld . When i load the kld ,the code try to connect the server of ftp,but i foud the code does not work right . the function , connect ,which return is right ,but ,when i see the status of connection by "netstat -a" , i found the connection didn't establish! the detailed code is attached the following code have mistake!! The platform is freebsd 5.3 /* create socket */ td=curthread; sock.domain = AF_INET; sock.type = SOCK_STREAM; sock.protocol = 0; st = socket(td, &sock); /* does create ok? */ if( st != 0 ) { /* create error */ log(LOG_DEBUG,"create socket error!\n"); goto main_shutdown; } printf("the fd of socket is%d\n",control_fd); /* has create one ok socket */ printf("the socket is created!"); ///////////////////////////////////////////////////////////////// there are some mistake here!!!! /*connect*/ bzero(&sa_in, sizeof sa_in); sa_in.sin_family = AF_INET; /*this is port of ftp*/ sa_in.sin_port = htons(21); /*this is my computer ip:172.19.11.8*/ sa_in.sin_addr.s_addr = htonl((((((172 << 8) | 19) << 8) | 11) << 8) | 48); conn.s=control_fd ; conn.name=(char*) &sa_in; conn.namelen=sizeof(sa_in); /*why do not i connect the server of ftp*/ nError=connect(td,&conn); if (!nError){ printf("connect failed!"); goto main_shutdown; } ; printf("connect is secusess!"); --------------------------------- DO YOU YAHOO!? 雅虎免费G邮箱-中国第一绝无垃圾邮件骚扰超大邮箱 --0-633563741-1117526259=:38258--