projects
/
my-code
/
ivac.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
cd6156a
)
blai
author
hackbard
<hackbard>
Wed, 16 Oct 2002 15:53:32 +0000
(15:53 +0000)
committer
hackbard
<hackbard>
Wed, 16 Oct 2002 15:53:32 +0000
(15:53 +0000)
stream.c
patch
|
blob
|
history
diff --git
a/stream.c
b/stream.c
index
b3527ab
..
1d4990d
100644
(file)
--- a/
stream.c
+++ b/
stream.c
@@
-20,6
+20,8
@@
/* inet_ntoa ... */
#include <arpa/inet.h>
/* inet_ntoa ... */
#include <arpa/inet.h>
+/* errno stuff ... */
+#include <errno.h>
int main(int argc, char *argv[]) {
int listen_fd, send_fd;
int main(int argc, char *argv[]) {
int listen_fd, send_fd;
@@
-41,8
+43,9
@@
int main(int argc, char *argv[]) {
local_addr.sin_addr.s_addr=htonl(INADDR_ANY);
memset(&(local_addr.sin_zero),'\0',8);
local_addr.sin_addr.s_addr=htonl(INADDR_ANY);
memset(&(local_addr.sin_zero),'\0',8);
- if(bind(listen_fd,
(struct sockaddr)
&local_addr,sizeof(struct sockaddr))==-1) {
+ if(bind(listen_fd,&local_addr,sizeof(struct sockaddr))==-1) {
printf("unable to bind on port %d.\n",atoi(argv[1]));
printf("unable to bind on port %d.\n",atoi(argv[1]));
+ perror("bind");
exit(1);
}
exit(1);
}
@@
-52,9
+55,9
@@
int main(int argc, char *argv[]) {
}
if(send_fd=accept(listen_fd,(struct sockaddr *)remote_addr,
}
if(send_fd=accept(listen_fd,(struct sockaddr *)remote_addr,
- sizeof(struct sockaddr_in)) {
+ sizeof(struct sockaddr_in))
!=1)
{
printf("accepting connection from %s port %d.\n",
printf("accepting connection from %s port %d.\n",
- inet_ntoa(remote_addr->sin_addr
.s_addr
),
+ inet_ntoa(remote_addr->sin_addr),
ntohs(remote_addr->sin_port));
/* send stuff .... */
ntohs(remote_addr->sin_port));
/* send stuff .... */
@@
-67,6
+70,7
@@
int main(int argc, char *argv[]) {
close(send_fd);
printf("connection closed ...\n");
close(send_fd);
printf("connection closed ...\n");
- prinrf("%d from %d total bytes sent.\n",send_bytes,read_bytes);
- return 0;
+ printf("%d from %d total bytes sent.\n",send_bytes,read_bytes);
+ }
+ return 0;
}
}