comparison src/network.c @ 1087:56c7ceb986a8

[gaim-migrate @ 1097] thank god, someone finally redid the proxy stuff. i think most of it works even. isn't that neat? thanks adam. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Sun, 12 Nov 2000 23:54:07 +0000
parents b402a23f35df
children
comparison
equal deleted inserted replaced
1086:ce201056e7a6 1087:56c7ceb986a8
16 * You should have received a copy of the GNU General Public License 16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 * 19 *
20 */ 20 */
21
22 #ifdef HAVE_CONFIG_H
23 #include "../config.h"
24 #endif
25 #include <netdb.h>
26 #include <gtk/gtk.h>
27 #include <unistd.h>
28 #include <errno.h>
29 #include <netinet/in.h>
30 #include <arpa/inet.h>
31 #include <string.h>
32 #include <stdlib.h>
33 #include <stdio.h>
34 #include <time.h>
35 #include <sys/socket.h>
36 #include "gaim.h"
37 #include "proxy.h"
38 #include "gnome_applet_mgr.h"
39
40 unsigned int *get_address(char *hostname)
41 {
42 struct hostent *hp;
43 unsigned int *sin=NULL;
44 if ((hp = proxy_gethostbyname(hostname))) {
45 sin = (unsigned int *)g_new0(struct sockaddr_in, 1);
46 memcpy(sin, hp->h_addr, hp->h_length);
47 }
48 return sin;
49 }
50
51 int connect_address(unsigned int addy, unsigned short port)
52 {
53 int fd;
54 struct sockaddr_in sin;
55
56 sin.sin_addr.s_addr = addy;
57 sin.sin_family = AF_INET;
58 sin.sin_port = htons(port);
59
60 fd = socket(AF_INET, SOCK_STREAM, 0);
61
62 if (fd > -1) {
63 if (quad_addr)
64 g_free (quad_addr);
65
66 quad_addr=g_strdup(inet_ntoa(sin.sin_addr));
67 if (proxy_connect(fd, (struct sockaddr *)&sin, sizeof(sin)) > -1) {
68 return fd;
69 }
70 }
71 return -1;
72 }
73