~ubuntu-branches/ubuntu/natty/9base/natty

« back to all changes in this revision

Viewing changes to lib9/dial.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2009-08-20 17:34:06 UTC
  • mfrom: (6.2.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090820173406-xpwqa9ruyevvc0ut
Tags: 1:3-3
* Updating maintainer field.
* Updating vcs fields.
* Updating package to standards version 3.8.3.
* Updatin variables writing in rules to consistent style.

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
        }
61
61
        free(buf);
62
62
 
63
 
        memset(&sa, 0, sizeof sa);
64
 
        memmove(&sa.sin_addr, &host, 4);
65
 
        sa.sin_family = AF_INET;
66
 
        sa.sin_port = htons(port);
67
63
        if((s = socket(AF_INET, proto, 0)) < 0)
68
64
                return -1;
69
65
                
98
94
                free(buf);
99
95
        }
100
96
 
101
 
        if(connect(s, (struct sockaddr*)&sa, sizeof sa) < 0){
102
 
                close(s);
103
 
                return -1;
 
97
        n = 1;
 
98
        setsockopt(s, SOL_SOCKET, SO_BROADCAST, &n, sizeof n);
 
99
        if(host != 0){
 
100
                memset(&sa, 0, sizeof sa);
 
101
                memmove(&sa.sin_addr, &host, 4);
 
102
                sa.sin_family = AF_INET;
 
103
                sa.sin_port = htons(port);
 
104
                if(connect(s, (struct sockaddr*)&sa, sizeof sa) < 0){
 
105
                        close(s);
 
106
                        return -1;
 
107
                }
104
108
        }
105
109
        if(proto == SOCK_STREAM){
106
110
                int one = 1;
114
118
                free(buf);
115
119
                return -1;
116
120
        }
 
121
        /* Allow regular files in addition to Unix sockets. */
 
122
        if((s = open(unix, ORDWR)) >= 0)
 
123
                return s;
117
124
        memset(&su, 0, sizeof su);
118
125
        su.sun_family = AF_UNIX;
119
126
        if(strlen(unix)+1 > sizeof su.sun_path){