Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 698914 Details for
Bug 912382
SOCK_STREAM TCP: send() returns success even other side responded with RST packet
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
Server source
tcp_server.c (text/plain), 2.42 KB, created by
Tomáš Hozza
on 2013-02-18 15:03:31 UTC
(
hide
)
Description:
Server source
Filename:
MIME Type:
Creator:
Tomáš Hozza
Created:
2013-02-18 15:03:31 UTC
Size:
2.42 KB
patch
obsolete
>#include <sys/types.h> >#include <sys/socket.h> >#include <netinet/in.h> >#include <stdio.h> >#include <unistd.h> >#include <stdlib.h> >#include <string.h> >#include <errno.h> >#include <signal.h> > >int main(int argc, char **argv) >{ > int ssock, csock, i; > static char buff[256]; > ssize_t nbytes; > struct sockaddr_in saddr; > > memset(&saddr, 0, sizeof(saddr)); > saddr.sin_family = AF_INET; > saddr.sin_port = htons(6666); > > signal(SIGPIPE, SIG_IGN); > > printf("Server started...\n"); > > if ((ssock = socket(AF_INET, SOCK_STREAM, 0)) < 0) { > printf("socket() error. (%d) %s\n", errno, strerror(errno)); > exit(1); > } > printf("Created SOCK_STREAM socket\n"); > > if (bind(ssock, (struct sockaddr*)&saddr, sizeof(saddr)) == -1) { > printf("bind() error. (%d) %s\n", errno, strerror(errno)); > close(ssock); > exit(1); > } > printf("Bound to localhost:6666\n"); > > if (listen(ssock, 1) == -1) { > printf("listen() error. (%d) %s\n", errno, strerror(errno)); > close(ssock); > exit(1); > } > > printf("waiting for connection...\n"); > csock = accept(ssock, NULL, NULL); > > if (csock == -1) { > printf("accept() error. (%d) %s\n", errno, strerror(errno)); > close(ssock); > exit(1); > } > printf("Client connected!\n"); > printf("Waiting for some data from client\n"); > > while ((nbytes = recv(csock, buff, sizeof(buff), 0)) > 0) { > printf("Received: \"%s\"\n", buff); > } > > if (nbytes < 0) { > printf("recv() error. (%d) %s\n", errno, strerror(errno)); > close(ssock); > close(csock); > exit(1); > } else if (nbytes == 0) { > printf("Received EOF\n"); > printf("Sending msg to client: \"MSG from server\"\n"); > if ((nbytes = send(csock, "MSG from server", sizeof("MSG from server"), 0)) <= 0) { > printf("send() error. (%d) %s\n", errno, strerror(errno)); > close(ssock); > close(csock); > exit(1); > } > } > > printf("sleep(5)\n"); > sleep(5); > > i = 1; > while (1) { > printf("Sending %d msg to client: \"MSG from server\"\n", i); > nbytes = send(csock, "MSG from server", sizeof("MSG from server"), 0); > printf("try #%d send() result: (%d) %s\n",i ,errno, strerror(errno)); > if (nbytes <= 0) > break; > ++i; > } > > printf("Server exiting...\n"); > close(ssock); > close(csock); > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 912382
:
698913
| 698914