Re: Exclusive access to IP-address



You mix several topics here.



I want to send data to a network printer, bypassing any Windows drivers. To
do this, I use this code to get a socket to that printer:



Your code actually goes via TDI and NDIS layers.



What I need is to block any other workstations or processes to open a
connection to that same IP-address. Can this be done?



No, this is cannot be done. Unless you install something on client's
machines to block access to IP.


The current program is written in Visual Studio 2005, C++, but if you know
another way or language to achieve this: any help is welcome.



Language does not matter. If you want to disallow connections to some
server, you can do this by modifying the code of server, so that it accepts
only special clients. If this is a network printer, and you are unable to
modify it's code, you have to redesign your solution.


--
V.
This posting is provided "AS IS" with no warranties, and confers no
rights.
"Marc" <Marc@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:9055537C-55C7-4486-A79F-F5C9028CC590@xxxxxxxxxxxxxxxx
I want to send data to a network printer, bypassing any Windows drivers. To
do this, I use this code to get a socket to that printer:

SOCKET ConnectSocket;

int InitIpConnection (char* strIPAddress, unsigned short sPort)
{
WSADATA wsaData;
int iResult = WSAStartup(MAKEWORD(2,2), &wsaData);
if (iResult != NO_ERROR)
{
return 1;
}
//----------------------
// Create a SOCKET for connecting to server
ConnectSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (ConnectSocket == INVALID_SOCKET)
{
WSACleanup();
return 2;
}
//----------------------
sockaddr_in clientService;
clientService.sin_family = AF_INET;
clientService.sin_addr.s_addr = inet_addr( strIPAddress );
clientService.sin_port = htons( sPort );

//----------------------
// Connect to server.
if ( connect( ConnectSocket, (SOCKADDR*) &clientService,
sizeof(clientService) ) == SOCKET_ERROR)
{
WSACleanup();
return 3;
}
return 0;
};

What I need is to block any other workstations or processes to open a
connection to that same IP-address. Can this be done?

The current program is written in Visual Studio 2005, C++, but if you know
another way or language to achieve this: any help is welcome.

Marc


.



Relevant Pages

  • Re: Socket Exception
    ... In this case the server most likely rejected your ... connection. ... Each command is a new socket connection that is opened and closed ... /// Required designer variable. ...
    (microsoft.public.win32.programmer.networks)
  • Re: ASP.NET 2.0 - a newbie question
    ... Is there some experienced ASP.NET 2.0 developer, ... server that comes bundled Microsoft VWDE. ... A connection attempt failed because the ... connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& ...
    (microsoft.public.dotnet.framework.aspnet)
  • error when move web service from dev machine to test server
    ... I have a simple web service that I developed on my laptop that resides ... test server, & when I try to run it, I get the error "No connection could be ... No connection could be made because the target machine actively refused it ... Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: Messaging alert
    ... I was hopping that I could use sockets to create a connection back and forth in order to send the message. ... I want to be able to send a file name and other information thru the client socket to then process in the servers. ... fileevent $sock w ... At the server side I am listening at the port and execute Accept2 when the socket is created. ...
    (comp.lang.tcl)
  • Re: Socket Exception
    ... In this case the server most likely rejected your ... connection. ... Each command is a new socket connection that is opened and closed ...
    (microsoft.public.win32.programmer.networks)