473,790 Members | 3,200 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

why error: "accept: Invalid argument"

when doing fork in a loop:
Expand|Select|Wrap|Line Numbers
  1. while(1) {
  2. tmp_sd = accept(sd, (struct sockaddr*)&tmp_sin, &len);
  3. if (tmp_sd == -1) {
  4. perror("accept");
  5. exit(0);
  6. }
  7.  
  8. //check client ip
  9.  
  10. //fork
  11. pid = fork();
  12. switch(pid) {
  13. case -1:
  14. perror("fork");
  15. break;
  16. case 0:
  17. _exit(0);
  18. }
  19.  
  20. close(tmp_sd);
  21. }
  22.  
If there's no fork, the code done well.
But if fork, when telnet, it has error: accept: Invalid argument
Thanks a lot.

Nov 16 '05 #1
12 7184
Yarco wrote:
when doing fork in a loop:
Expand|Select|Wrap|Line Numbers
  1.          while(1) {
  2.                  tmp_sd = accept(sd, (struct sockaddr*)&tmp_sin, &len);
  3.                  if (tmp_sd == -1) {
  4.                          perror("accept");
  5.                          exit(0);
  6.                  }
  7.                  //check client ip
  8.                  //fork
  9.                  pid = fork();
  10.                  switch(pid) {
  11.                          case -1:
  12.                                  perror("fork");
  13.                                  break;
  14.                          case 0:
  15.                                  _exit(0);
  16.                  }
  17.                  close(tmp_sd);
  18.          }
  19.  
If there's no fork, the code done well.
But if fork, when telnet, it has error: accept: Invalid argument


Platform or compiler specific questions are best asked in a
newsgroup where they are topical.
There are no functions accept(), perror(), fork(), close(), and
_exit() in standard C, so I won't say anything about their use.
comp.unix.progr ammer might be a good place to ask.

Your switch definitely lacks a default, though, to ward against
unexpected pid values. printf() debug from there...
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Nov 16 '05 #2
Thanks

Nov 16 '05 #3
On Wed, 16 Nov 2005 06:02:15 +0100, Michael Mair wrote:
Yarco wrote:
when doing fork in a loop:
Expand|Select|Wrap|Line Numbers
  1.          while(1) {
  2.                  tmp_sd = accept(sd, (struct sockaddr*)&tmp_sin, &len);
  3.                  if (tmp_sd == -1) {
  4.                          perror("accept");
  5.                          exit(0);
  6.                  }
  7.                  //check client ip
  8.                  //fork
  9.                  pid = fork();
  10.                  switch(pid) {
  11.                          case -1:
  12.                                  perror("fork");
  13.                                  break;
  14.                          case 0:
  15.                                  _exit(0);
  16.                  }
  17.                  close(tmp_sd);
  18.          }
  19.  
If there's no fork, the code done well.
But if fork, when telnet, it has error: accept: Invalid argument


Platform or compiler specific questions are best asked in a
newsgroup where they are topical.
There are no functions accept(), perror(), fork(), close(), and
_exit() in standard C, so I won't say anything about their use.

[snip]

Isn't perror() part of the standard? It's declared in stdio.h.

Regards,
Gary

Nov 16 '05 #4
Gary Baydo wrote:
Isn't perror() part of the standard? It's declared in stdio.h.


perror() is in the standard library.

--
pete
Nov 16 '05 #5
Gary Baydo wrote:
On Wed, 16 Nov 2005 06:02:15 +0100, Michael Mair wrote:

Yarco wrote:
when doing fork in a loop:
Expand|Select|Wrap|Line Numbers
  1.         while(1) {
  2.                 tmp_sd = accept(sd, (struct sockaddr*)&tmp_sin, &len);
  3.                 if (tmp_sd == -1) {
  4.                         perror("accept");
  5.                         exit(0);
  6.                 }
  7.                 //check client ip
  8.                 //fork
  9.                 pid = fork();
  10.                 switch(pid) {
  11.                         case -1:
  12.                                 perror("fork");
  13.                                 break;
  14.                         case 0:
  15.                                 _exit(0);
  16.                 }
  17.                 close(tmp_sd);
  18.         }
If there's no fork, the code done well.
But if fork, when telnet, it has error: accept: Invalid argument


Platform or compiler specific questions are best asked in a
newsgroup where they are topical.
There are no functions accept(), perror(), fork(), close(), and
_exit() in standard C, so I won't say anything about their use.


[snip]

Isn't perror() part of the standard? It's declared in stdio.h.


You are right, thanks for the correction. I got carried away
before breakfast... I really should enforce my "no newsgroups
before caffeine" policy.

Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Nov 16 '05 #6
A.A
>tmp_sd = accept(sd, (struct sockaddr*)&tmp_ sin, &len);
int
accept(int s,
struct sockaddr * restrict addr,
socklen_t * restrict addrlen);
///////////////////////////////////////
case 0: {
(void)printf("t est........?");
_exit(0);
}

Nov 16 '05 #7
A.A
>tmp_sd = accept(sd, (struct sockaddr*)&tmp_ sin, &len);
int
accept(int s,
struct sockaddr * restrict addr,
socklen_t * restrict addrlen);
///////////////////////////////////////
case 0: {
(void)printf("t est........?");
_exit(0);
}

Nov 16 '05 #8
A.A
>tmp_sd = accept(sd, (struct sockaddr*)&tmp_ sin, &len);
int
accept(int s,
struct sockaddr * restrict addr,
socklen_t * restrict addrlen);
///////////////////////////////////////
case 0: {
(void)printf("t est........?");
_exit(0);
}

Nov 16 '05 #9
A.A
>tmp_sd = accept(sd, (struct sockaddr*)&tmp_ sin, &len);
int
accept(int s,
struct sockaddr * restrict addr,
socklen_t * restrict addrlen);
///////////////////////////////////////
case 0: {
(void)printf("t est........?");
_exit(0);
}

Nov 16 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2034
by: vincent wehren | last post by:
Hi, Trying to grasp Py_NewInterpreter()in a simple app embedding Python, I was wondering why the following gives me an error: int main() { PyThreadState *tstate; Py_Initialize();
0
1859
by: Richard | last post by:
I am writing a script which accesses a DBM file using SDBM. The program works but throws out a warning of: - Argument "O_RDWR" isn't numeric in null operation I've included Fcntl but that doesn't solve the problem. Does anyone why this is happening? Thanks
3
3013
by: Stephen Poley | last post by:
Could some kind soul explain the errors and warnings that the W3C CSS validator generates for page: http://www.atlis.nl/testsite/nl/ Results at: http://tinyurl.com/5pxqx The error "Invalid number : borderParse Error - " may be due to something I've done, but I'm blowed if I can see what. While the warning "property display doesn't exist for media" has me baffled.
9
1966
by: Wally | last post by:
I am trying to display images from an Access 2000 database and I get an error "Invalid Parameter Used" when I execute the code line "picBLOB.Image = Image.FromStream(stmBLOBData)" in my Visual Basic .Net application. I have researched MSDN for help and found the example article 321900 (see below) and set up a test and everything works fine when I use SQL Server 2000 but when I modify the code and use data from Access 2000 using an...
0
1826
by: Simon Harris | last post by:
I'm trying to access a password protected web service. My code is as follows: Dim BS7666 As New bs7666.BS7666 'New instance of my web service Dim CredCache As CredentialCache = New CredentialCache Dim WebSvcURL As System.Uri = New System.Uri(BS7666.Url) CredCache.Add(WebSvcURL, "Basic", New NetworkCredential("USERNAME", "PASSWORD", "DOMAIN")) 'This is the line it fails on BS7666.Credentials = CredCache Dim DataSet_bs7666 As New...
6
2147
by: Patrick Dugan | last post by:
Hello, I'm trying to load different images (icons) into a PictureBox1.Image. The first image loads just fine, but the second image always returns the error "Invalid property used." It doesn't matter what icons are loaded. The first always shows up and any icons after that give me the error. Here is the offending code: The "DestinationPath" variable is the full path and filename of the icon
3
2590
by: Arnold | last post by:
I am having problem loading the image from the database. It gives this error: "Invalid parameter used." This is my source code: Private abyt() As Byte Private fo As New OpenFileDialog Private sf As New SaveFileDialog Dim strCn As String = "Data Source=DATABASE\BARCA;" & _ "Initial Catalog=MIS;Integrated Security=SSPI" Dim cn As SqlConnection = New SqlConnection(strCn) Dim fs As IO.FileStream
3
7426
by: Martin | last post by:
Hi, I have an aspx page with two dropdownlist controls. I update the options in the second ddl based on selection made in the first. I do this with the ICallbackEventHandler interface, as per "Implementing Client Callbacks Without Postbacks in ASP.NET Web Pages" (http://msdn2.microsoft.com/en-us/library/ms178208.aspx) This works.
1
8032
by: Java Guy | last post by:
I'm trying to view a web page. IE tells me there are (Java?) errors on the page. Here they are: Line: 15 Char: 7 Error: Wrong number of arguments or invalid propert assignment Code: 0 URL: http://(address.of.my.webcam):port/LiveView.html and
0
10419
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10201
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10147
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9023
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7531
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5424
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5552
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3709
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2910
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.