/[rdesktop]/sourceforge.net/trunk/rdesktop/tcp.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/trunk/rdesktop/tcp.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 33 by matty, Sat Sep 15 12:34:34 2001 UTC revision 275 by astrand, Tue Nov 19 14:48:02 2002 UTC
# Line 1  Line 1 
1  /*  /*
2     rdesktop: A Remote Desktop Protocol client.     rdesktop: A Remote Desktop Protocol client.
3     Protocol services - TCP layer     Protocol services - TCP layer
4     Copyright (C) Matthew Chapman 1999-2001     Copyright (C) Matthew Chapman 1999-2002
5        
6     This program is free software; you can redistribute it and/or modify     This program is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by     it under the terms of the GNU General Public License as published by
# Line 31  Line 31 
31  static int sock;  static int sock;
32  static struct stream in;  static struct stream in;
33  static struct stream out;  static struct stream out;
34    extern int tcp_port_rdp;
35    
36  /* Initialise TCP transport data packet */  /* Initialise TCP transport data packet */
37  STREAM  STREAM
# Line 83  tcp_recv(int length) Line 84  tcp_recv(int length)
84    
85          while (length > 0)          while (length > 0)
86          {          {
87                  ui_select(sock);                  if (!ui_select(sock))
88                            /* User quit */
89                            return NULL;
90    
91                  rcvd = recv(sock, in.end, length, 0);                  rcvd = recv(sock, in.end, length, 0);
92                  if (rcvd == -1)                  if (rcvd == -1)
# Line 109  tcp_connect(char *server) Line 112  tcp_connect(char *server)
112    
113          if ((nslookup = gethostbyname(server)) != NULL)          if ((nslookup = gethostbyname(server)) != NULL)
114          {          {
115                  memcpy(&servaddr.sin_addr, nslookup->h_addr,                  memcpy(&servaddr.sin_addr, nslookup->h_addr, sizeof(servaddr.sin_addr));
                        sizeof(servaddr.sin_addr));  
116          }          }
117          else if (!(servaddr.sin_addr.s_addr = inet_addr(server)))          else if (!(servaddr.sin_addr.s_addr = inet_addr(server)))
118          {          {
# Line 125  tcp_connect(char *server) Line 127  tcp_connect(char *server)
127          }          }
128    
129          servaddr.sin_family = AF_INET;          servaddr.sin_family = AF_INET;
130          servaddr.sin_port = htons(TCP_PORT_RDP);          servaddr.sin_port = htons(tcp_port_rdp);
131    
132          if (connect          if (connect(sock, (struct sockaddr *) &servaddr, sizeof(struct sockaddr)) < 0)
             (sock, (struct sockaddr *) &servaddr,  
              sizeof(struct sockaddr)) < 0)  
133          {          {
134                  error("connect: %s\n", strerror(errno));                  error("connect: %s\n", strerror(errno));
135                  close(sock);                  close(sock);
136                  return False;                  return False;
137          }          }
138    
139          setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (void *) &true,          setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (void *) &true, sizeof(true));
                    sizeof(true));  
140    
141          in.size = 4096;          in.size = 4096;
142          in.data = xmalloc(in.size);          in.data = xmalloc(in.size);
# Line 150  tcp_connect(char *server) Line 149  tcp_connect(char *server)
149    
150  /* Disconnect on the TCP layer */  /* Disconnect on the TCP layer */
151  void  void
152  tcp_disconnect()  tcp_disconnect(void)
153  {  {
154          close(sock);          close(sock);
155  }  }

Legend:
Removed from v.33  
changed lines
  Added in v.275

  ViewVC Help
Powered by ViewVC 1.1.26