Network Programming in C
Network Programming in C
(OP)
Does anyone know or have any programs that do the following:
- A Client writes and reads to a flat file from a Server.
- The Server must send acknowledgements and each packet must be sequenced.
- A Client writes and reads to a flat file from a Server.
- The Server must send acknowledgements and each packet must be sequenced.
RE: Network Programming in C
hnd
hasso55@yahoo.com
RE: Network Programming in C
The first part could be done a number of ways depending on your server configuration. One way is to use HTTP to read the file and FTP to write the file which would involve sockets. You could also set up NFS on the server, export the relevant file systems and then mount them on the client which would be simpler and would only involve basic file i/o.
You don't mention what platform the client program will run on. If it's a flavor of UNIX, check out UNIX Network Programming by W. Richard Stevens for good explanations and examples of sockets programming.
Barring that, do a web search for "sockets," "network programming," and/or "winsock programming" (if you're writing it for Windows).
HTH,
Russ
bobbitts@hotmail.com
http://home.earthlink.net/~bobbitts
RE: Network Programming in C
If you want to write Software for that Problem: I have posted some examples in July in the Forum.
If I Remember correct the Thread was posted by Trainlogan.
The Forum was c or c++ ???
There is no big difference between Berkley Socket or Winsock programming.
hnd
hasso55@yahoo.com
RE: Network Programming in C
on 29th July there is a thread in the Borland C++ Forum posted by trainlogan with two examples (One Server, One Client) for Windows NT/9x
hnd
hasso55@yahoo.com
RE: Network Programming in C
Is there a function in C, that can read the date(last modified, Last accessed, and last accessed) and length of a file.
I know length is easy, point the pointer to the end of the file and the return value is the length. But is there a function to realize this?
Thanks
RE: Network Programming in C
hnd
hasso55@yahoo.com
RE: Network Programming in C
Russ
bobbitts@hotmail.com
http://home.earthlink.net/~bobbitts
RE: Network Programming in C
I solved this problem using stat(), it not only can read the last update time but also last modified time and length.
Now I have another problem.
I run a server in an eternal loop.
I need to close the socket after I press ^c, so I use
signal(SIGTERM,cleanEXIT);
signal(SIGINT,cleanEXIT);
Then in the top of the program.
I use :
int listenfd;
void cleanEXIT()
{
close(listenfd);
/* clean up the garbage processes*/
while(waitpid(-1,NULL,WNOHANG)>0);
printf("Byebye");
exit(0);
}
But the problem is the the socket "listenfd" did not close.
I define listenfd as a global variable.
when I open it ,as :
ptnb=atoi(argv[1]);
listenfd=socket(AF_INET,SOCK_STREAM,0);
What is wrong with my program?
RE: Network Programming in C
On the server side:
I used setsockopt before I bind() listenfd to the serversocket.
But after clients requested, then exit and the server responses, then exit. The socket still does not released.
Why is that happen?
RE: Network Programming in C
hnd
hasso55@yahoo.com
RE: Network Programming in C
I met a new problem here: when I compile the program, I find
the following error. What does it mean?
Undefined first referenced
symbol in file
gethostbyname /var/tmp/ccV065JB.o (symbol belongs to impl
icit dependency /usr/lib/libnsl.so.1)
inet_ntoa /var/tmp/ccV065JB.o (symbol belongs to impl
icit dependency /usr/lib/libnsl.so.1)
ld: fatal: Symbol referencing errors. No output written to se
collect2: ld returned 1 exit status
I have included all the .h files I believe is necessary.
What is the possibility of this problem.
Thanks