Prev: IPC based on name pipe FIFO and transaction log file
Next: Learn about proxy sites and how to use them to open blocked sites unlimited downloads from RapidShare and megaupload and increase the speed of the Internet with new sites for free
From: Bill Cunningham on 2 Apr 2010 14:40 Well this is what I have so far. I believe I'm doing this right. #include <stdio.h> #include <sys/socket.h> int smtp,pop,ftp; smtp=socket(AF_INET,SOCK_DGRAM,25); pop=socket(AF_INET,SOCK_DGRAM,109); ftp=socket(AF_INET,SOCK_DGRAM,21); This should declare the socket(s). Bill
From: Rick Jones on 2 Apr 2010 14:55 Bill Cunningham <nospam(a)nspam.invalid> wrote: > Well this is what I have so far. I believe I'm doing this right. I am afraid your belief is not grounded in reality :) > #include <stdio.h> > #include <sys/socket.h> > int smtp,pop,ftp; > smtp=socket(AF_INET,SOCK_DGRAM,25); > pop=socket(AF_INET,SOCK_DGRAM,109); > ftp=socket(AF_INET,SOCK_DGRAM,21); > This should declare the socket(s). AF_INET + SOCK_DGRAM gives you a socket you can use for UDP not TCP. SMTP, POP and FTP want a TCP connection, which means a SOCK_STREAM socket. Further, the protocol argument to the socket() call is to specify the transport protocol, not the service's port number in the transport protocol. You would either default it (value of 0) and rely on AF_INET + SOCK_STREAM giving you a TCP endpoint, or use the explicit value for TCP. Do definitely get either Unix Network Programming or some similar work. It will be invaluable. rick jones -- No need to believe in either side, or any side. There is no cause. There's only yourself. The belief is in your own precision. - Joubert these opinions are mine, all mine; HP might not want them anyway... :) feel free to post, OR email to rick.jones2 in hp.com but NOT BOTH...
From: Rainer Weikusat on 2 Apr 2010 15:33 "Bill Cunningham" <nospam(a)nspam.invalid> writes: > Well this is what I have so far. I believe I'm doing this right. > > #include <stdio.h> > #include <sys/socket.h> > > int smtp,pop,ftp; > > smtp=socket(AF_INET,SOCK_DGRAM,25); > pop=socket(AF_INET,SOCK_DGRAM,109); > ftp=socket(AF_INET,SOCK_DGRAM,21); > > This should declare the socket(s). In addition to the errors already mentioned by Rick Jones, there is a deeper misunderstanding here: Your three statements are not declarations (of equivalence), as if they were equations. int smtp, pop, ftp; is both a declaration and a definition of the three integer variables. smtp = socket(AF_INET, SOCK_STREAM, 0); pop = socket(AF_INET, SOCK_STREAM, 0); are assignment statments whose right side causes a particular system call (public kernel subroutine) to be executed which returns a value of type int which is then assigned to the object mentioned on the left side of the assignment operator. The difference is that this a procedural description of an activity the computer is supposed to perform.
From: Bill Cunningham on 2 Apr 2010 16:38 "Rick Jones" <rick.jones2(a)hp.com> wrote in message news:hp5ejk$sm3$3(a)usenet01.boi.hp.com... > Do definitely get either Unix Network Programming or some similar > work. It will be invaluable. I'm just afraid that it will talk only about AF_UNIX and not get into internet networking. I understand there is a differenct in unix socket used internally by the machine and internet communication. Bill
From: Bill Cunningham on 2 Apr 2010 16:43
"Rainer Weikusat" <rweikusat(a)mssgmbh.com> wrote in message news:8739zdlkdy.fsf(a)fever.mssgmbh.com... > In addition to the errors already mentioned by Rick Jones, there is a > deeper misunderstanding here: Your three statements are not > declarations (of equivalence), as if they were equations. > > int smtp, pop, ftp; > > is both a declaration and a definition of the three integer variables. > > smtp = socket(AF_INET, SOCK_STREAM, 0); > pop = socket(AF_INET, SOCK_STREAM, 0); > > are assignment statments whose right side causes a particular system > call (public kernel subroutine) to be executed which returns a value > of type int which is then assigned to the object mentioned on the left > side of the assignment operator. The difference is that this a > procedural description of an activity the computer is supposed to > perform. I'm not quite sure what you're saying but the return values are going to be stored in smtp for example and I will pass smtp as the first parameter of connect() for example. Bill |