WaitNamedPipe() Issue

This is a discussion on WaitNamedPipe() Issue within the Windows Programming forums, part of the Platform Specific Boards category; lol, no offense taken Yes. Every time i make changes to the server code i remove the old one and ...

  1. #16
    Registered User IndioDoido's Avatar
    Join Date
    Apr 2007
    Posts
    194
    lol, no offense taken

    Yes. Every time i make changes to the server code i remove the old one and then install the newer version, then run it from windows services.
    "Artificial Intelligence usually beats natural stupidity."

  2. #17
    Registered User IndioDoido's Avatar
    Join Date
    Apr 2007
    Posts
    194
    I think the problem is really in the authentication :S

    This project uses windows authentication between the client and server.
    If i'm in a specific account sending a message through a named pipe to a server, the server machine must accept my account.

    How do i make the server accept my account? If this is actually the issue...
    "Artificial Intelligence usually beats natural stupidity."

  3. #18
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    Quote Originally Posted by IndioDoido View Post
    I think the problem is really in the authentication :S

    This project uses windows authentication between the client and server.
    If i'm in a specific account sending a message through a named pipe to a server, the server machine must accept my account.

    How do i make the server accept my account? If this is actually the issue...
    Again, my caveat, I'm not a Network/Security administrator.

    At the target workstation, right click on My computer, click on manage, click on Local users and Groups, Select Groups in the right pane. There should be an Administrators group listed. Add your userid to this group. Click on Ok etc to back out. Reboot the target workstation and go into control panel and select user accounts. you should see your user account listed. Reset the password of this account to match your password. Once this is done try your app.

    One other thing. since I work with Active directory, I have always had to preface the added user account with the domain. For Instance, when I added my account to the Local Admin group, I had to use Domain\123456. I' m not sure if you will have to do that. You may just need to add 123456.

  4. #19
    Registered User IndioDoido's Avatar
    Join Date
    Apr 2007
    Posts
    194
    At the target workstation, right click on My computer, click on manage, click on Local users and Groups, Select Groups in the right pane. There should be an Administrators group listed. Add your userid to this group.
    When you say to add my userid to that group, do you mean the userid i use in the host machine? If so, how can i get my userid? :S
    "Artificial Intelligence usually beats natural stupidity."

  5. #20
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    When you say to add my userid to that group, do you mean the userid i use in the host machine? If so, how can i get my userid? :S
    You should find your userid (user name) from the task manager. It's the Users tab. What type of network are you on? Is it a school network, home network or corporate network?

    But anyway, I don't think it's an authentication issue because if it were, the returned error code would be 1326, Logon failure: Unknown user name or bad password.

    The error 3 indicates that it's a poorly formed path. Humor me again and change this

    Code:
    char *pszPipe="\\\\192.168.1.82\\pipe\\ServNT";
    to this

    Code:
    char pszPipe[] = {"\\\\192.168.1.82\\pipe\\ServNT"};
    Last edited by BobS0327; 11-10-2008 at 09:03 PM.

  6. #21
    Registered User IndioDoido's Avatar
    Join Date
    Apr 2007
    Posts
    194
    oh! i thought that userid was different from user name, sorry :S

    ok, i will humor you...
    after changing:
    Code:
    char *pszPipe="\\\\192.168.1.82\\pipe\\ServNT";
    to this
    Code:
    char pszPipe[] = {"\\\\192.168.1.82\\pipe\\ServNT"};
    i can know access the server
    but........i know get a SetNamedPipeHandlerState error.
    At least we are progressing
    "Artificial Intelligence usually beats natural stupidity."

  7. #22
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by IndioDoido View Post
    oh! i thought that userid was different from user name, sorry :S

    ok, i will humor you...
    after changing:
    Code:
    char *pszPipe="\\\\192.168.1.82\\pipe\\ServNT";
    to this
    Code:
    char pszPipe[] = {"\\\\192.168.1.82\\pipe\\ServNT"};
    i can know access the server
    but........i know get a SetNamedPipeHandlerState error.
    At least we are progressing

    That change should make absolutely NO DIFFERENCE, other than as to how the memory is actually allocated for the variable. If it does, I'm guessing you are getting some sort of memory overwrite problem.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  8. #23
    Registered User IndioDoido's Avatar
    Join Date
    Apr 2007
    Posts
    194
    your right!

    i changed it back to:
    Code:
    char *pszPipe="\\\\192.168.1.82\\pipe\\ServNT";
    and it "works"...

    really strange :S
    i might have been doing something wrong, but anyway, at least now i can access the server.

    How can i resolve this other error?
    SetNamedPipeHandlerState error
    "Artificial Intelligence usually beats natural stupidity."

  9. #24
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    What is the exact error code?
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  10. #25
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    Quote Originally Posted by IndioDoido View Post
    your right!

    i changed it back to:
    Code:
    char *pszPipe="\\\\192.168.1.82\\pipe\\ServNT";
    and it "works"...

    really strange :S
    i might have been doing something wrong, but anyway, at least now i can access the server.

    How can i resolve this other error?
    The error that you were getting, error 3 "System cannot find the specified path" indicated that the path was poorly formed which indicated that there was something wrong with *pszPipe. But yet I kept staring at that variable and my mind told me that there wasn't anything wrong with it. I just didn't want to believe the returned error code because *pszPipe looked correct to me.

    I can't recreate the error. Otherwise, I'd run it thru Ollydbg and tell you exactly what the issue is.

  11. #26
    'Allo, 'Allo, Allo
    Join Date
    Apr 2008
    Posts
    611
    Quote Originally Posted by IndioDoido View Post
    your right!
    and it "works"...
    Are you sure? Your error checking code is contains errors

    Code:
     hPipe = CreateFile(pszPipe, GENERIC_WRITE|GENERIC_READ, 0, NULL,
                           OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
    	if (hPipe==NULL) 
    	{
    		printf("CLIENT: Error a connecting \n");
    		return 1;
    	}
    hPipe will never equal NULL as CreateFile returns INVALID_HANDLE_VALUE when it fails.

  12. #27
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    Quote Originally Posted by adeyblue View Post
    Are you sure? Your error checking code is contains errors

    Code:
     hPipe = CreateFile(pszPipe, GENERIC_WRITE|GENERIC_READ, 0, NULL,
                           OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
    	if (hPipe==NULL) 
    	{
    		printf("CLIENT: Error a connecting \n");
    		return 1;
    	}
    hPipe will never equal NULL as CreateFile returns INVALID_HANDLE_VALUE when it fails.
    Good catch.

    This probably is the source of his SetNamedPipeHandlerState error since CreateFile will always be considered to execute successfully whether or not it was actually successful using his current code.

  13. #28
    Registered User IndioDoido's Avatar
    Join Date
    Apr 2007
    Posts
    194
    hey everyone!

    My client and server apps are working nicely on the same machine. I can send command lines from the client app to the server via pipe and the server runs 's the commands. How can there be an error in the code if i can accomplish these tasks?

    About the issue of not connecting to my VM. My teacher said that to communicate from different machines in this project i have to be logged as the same user in both machines :S and for that i have to use a some "start" command line. For example, before a run the client app on the host machine i have to log-on to the VM, and for that i run this command:
    Code:
    start \\vmIP Username Password
    After that i run my client app.

    That's what i did...and know i can access the server.
    But.....when i send a command line from the client app to the server, the server gives me a "ReadFile error 109" in the event viewer

    Why is that happening?
    Last edited by IndioDoido; 11-11-2008 at 06:24 PM.
    "Artificial Intelligence usually beats natural stupidity."

  14. #29
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    Quote Originally Posted by adeyblue View Post
    Are you sure? Your error checking code is contains errors

    Code:
     hPipe = CreateFile(pszPipe, GENERIC_WRITE|GENERIC_READ, 0, NULL,
                           OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
    	if (hPipe==NULL) 
    	{
    		printf("CLIENT: Error a connecting \n");
    		return 1;
    	}
    hPipe will never equal NULL as CreateFile returns INVALID_HANDLE_VALUE when it fails.
    As adeyblue points out, you're incorrectly checking the return value of Create File

    It should be:

    Code:
    if (hPipe==INVALID_HANDLE_VALUE) 
    	{
    		printf("CLIENT: Error a connecting \n");
    		return 1;
    	}
    The reason being is that INVALID_HANDLE_VALUE is 6 and if memory serves me correctly, NULL evaluates to 0 (zero). Thus, your CreateFile call will ALWAYS be successful whether or not it is actually successful. If CreateFile fails, it will return six not zero.

    The 109 error translates to "the named pipe has ended". Normally, this should be an informational message. Named pipes work in the following manner:

    The server makes a client connection, communicates with the client until the client disconnects casuing ReadFile to return FALSE. it then disconnects the server side connection which causes the "109 the name pipe has ended" message. and then the server attempts to connect to another client.

    Thus, under normal circumstances the 109 message is just an informational message.

  15. #30
    Registered User IndioDoido's Avatar
    Join Date
    Apr 2007
    Posts
    194
    hi BobS0327

    i've changed the error checking code to:
    Code:
    if (hPipe==INVALID_HANDLE_VALUE)
    I still get the same error in the event viewer when i send a command to the server
    But, in the client side i now "trigger" this checking:
    Code:
    	if (!SetNamedPipeHandleState(hPipe,&dwMode,NULL,NULL)) 
    	{
    		printf("CLIENT: Error SetNamedPipeHandleState\n");
    		return 1;
    	}
    Last edited by IndioDoido; 11-12-2008 at 07:02 PM.
    "Artificial Intelligence usually beats natural stupidity."

Page 2 of 3 FirstFirst 123 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. float calculation issue
    By George2 in forum C# Programming
    Replies: 1
    Last Post: 05-26-2008, 04:56 AM
  2. re-entrancy pattern issue setbacks
    By George2 in forum Windows Programming
    Replies: 0
    Last Post: 04-12-2008, 02:23 AM
  3. type safe issue
    By George2 in forum C++ Programming
    Replies: 4
    Last Post: 02-12-2008, 08:32 PM
  4. Idle Issue.
    By Charmy in forum C++ Programming
    Replies: 7
    Last Post: 06-24-2005, 06:10 AM
  5. my first issue of GDM
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 09-12-2002, 04:02 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21