Click here to Skip to main content
15,915,513 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is server coding.
i want to connect it with remote system... i added the ip address of the system.
but its not create.why?
#include "stdafx.h"
#include<windows.h>
#include<stdio.h>
int main(int argc,char* argv)
{
	HANDLE h;
	BOOL con;
	DWORD byt;
	char buffer[1024];
	h=CreateNamedPipe("\\\\172.16.11.30\\pipe\\p",PIPE_ACCESS_DUPLEX |FILE_FLAG_OVERLAPPED|FILE_FLAG_WRITE_THROUGH,PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,PIPE_UNLIMITED_INSTANCES,512,512,NMPWAIT_USE_DEFAULT_WAIT,NULL);

	if (h == INVALID_HANDLE_VALUE) 
      {
          printf(TEXT("CreateNamedPipe failed, GLE=%d.\n"), GetLastError()); 
          return -1;
      }
	else
		printf("created sucessfullly\n");
	con=ConnectNamedPipe(h,NULL);
	ReadFile(h,buffer,sizeof(buffer),&byt,NULL);
	printf("The data is %s\n",buffer);
	CloseHandle(h);
	return 0;
}

can you help me
Posted
Updated 30-Jun-11 21:23pm
v3
Comments
Smithers-Jones 1-Jul-11 11:41am    
Please use a descriptive headline for your posts. "This is not working" isn't helpful at all.

I think with that code what you end up trying to do is attempting to create a pipe on a remote computer, which is not possible. You can only create a pipe on your local machine, if a pipe is already created elsewhere, you can access with CallNamedPipe().

You should probably read a little more documentation, try this:
http://www.winsocketdotnetworkprogramming.com/winsock2programming/winsock2advancednamedpipe15.html[^]
 
Share this answer
 
Comments
#realJSOP 1-Jul-11 10:29am    
5 - correct answer - named pipes to remote systems is not possible. Pipes can only be created on the box you're on.
Albert Holguin 1-Jul-11 10:35am    
thanks john
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900