.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Post New Web Links

Advanced Socket Connections - Connect using IP and MAC address

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :WPF
In .NET, is there any way to specify both an IP and a MAC address when connecting to a socket endpoint?

Here's the problem I'm trying to solve:
I'm building a peer to peer type application (not a file share app!) and I need the clients to be able to talk to each other.  If the MAC address is already known ahead of time (provided by a centralized server), is there any way to connect to the host and specify the MAC?

I've got a background in CISCO as well and I am pretty sure that technologically this is possible, however, I'm not sure if the sockets classes supports that.

View Complete Post

More Related Resource Links

Advanced Basics: What's My IP Address?


If you're like me, you regularly do tech-support for family, friends, and neighbors. You can't go to a party without hearing the familiar refrain: "I've just got a quick question. " It's always something-their Internet connections get dropped, they've got a virus, they can't install some piece of hardware, or some file has gone missing.

Ken Getz

MSDN Magazine December 2005

Is it possible to connect to a machine within a Lan if given mac address?

If a machine is within a Lan, with a Lan IP address such as, and its mac address is fixed and known, such as A4:B5:......, the machine is connected to internet through a router with a public IP address. Is it possible to directly connect to the machine from internet using its router IP address and its mac address?   thanksRegards! directfriends.net

Can connect by IP address but not by name

I have setup WSS 3.0 on a Server 2008 (32-bit) machine using the directions from this site: http://grounding.co.za/blogs/brett/archive/2007/08/23/a-developer-s-101-to-installing-windows-sharepoint-services-3-0.aspx I have created a site collection which I can connect to on the server.  When I try to access the site from either my laptop or other desktop, I can only get to the site by entering the IP address of the server.  The site name returns "Internet Explorer cannot display the webpage" I have disabled every firewall including the router. I checked SQL and the account has the recommended administration rights. I tried flushdns. What am I missing?

Windows 7 socket bind behavior difference from XP/Server 2003, with reuse address socket option (WSA


I have two processes that are both listening to UDP packets and can run on the same PC.  One process binds a socket to one NIC address with port 18246.  The other process has two Socket objects, one for sending on port 18246 and one for listening on port 18246.  Both of these sockets are created, have the SO_REUSEADDR socket option set.  Bind is called for a single IP Endpoint for a common local NIC address, but a different one than used by the above app.

Under Windows XP and server 2003, both processes can bind regardless of order of startup.

Under Windows 7, if the process with only one socket starts first, the second process fails with WSAEACCES 10013 error with the second socket bind.

I wrote a sample C# app with the following method that fails when running under Windows 7 x86 and x64.  The above failure occurs when the sockets are in separate processes, but a single process using the same socket interaction also fails.  The below method is called with two IPV4 addresses that are assigned to local Network adapters on the PC.

Only one usage of each socket address (protocol/network address/port) is normally permitted IN C# Re



 I done an application in Remoting.Consider a server is running in my machine an listenening the port 8085(Remoting.Configure()) ,I have 2000 Clients They ALL send an update every 2MIN to the server through 8085.

I configure the port like this:

  1. public

  1. void InitNew()
  2. {
  3. try
  4. {
  5. if(_regcnt ==2)
  6. {
  7. MessageBox.Show("Unable to run the server you must restart the system","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
  8. Application.Exit();
  9. return ;
  10. }
  11. UNReg();
  12. chan=
  13. new TcpChannel(8085);
  14. ChannelServices.RegisterChannel(chan);

How to connect a remote Sqlserver 2008 r2 server with IP address and port? I use SMO and VS2010.


how to write SMO's conn.ConnectionString with IP address and port?

connect to a socket


Hi there,

I am trying to write a simple .net program (to beign with) that will tell me if a particular port is up or down on clients servers at a particular ip address. Example is ping an ipaddress/hostname for ports 21, 25, 110, 80 and it will reply up or if it times out after say 30 seconds or a minute down.

I have found some code on the net and edited it to return if a port is opened or closed.

  protected void btnSubmit_Click(object sender, EventArgs e)
  int StartPort;        
StartPort = Convert.ToInt32(txtStartPort.Text);
        int CurrPort = StartPort;

            TcpClient TcpScan = new TcpClient();

                TcpScan.Connect(txtHost.Text, CurrPort);
                txtPing.Text =("Port " + CurrPort + " open");
                txtPing.BackColor = Color.Green;

                txtPing.Text = ("Port " + CurrPort + " closed");
                txtPing.BackColor = Color.Red;



I will have a DB with many records in them, i will group those records by customer and each customer will have a box in a repeater, in that box several lines (depending on how many ports they have) and so the code will go green or red according to those ports. My

Clean termination of socket connections.


I'm finding the MSDN docs confusing for socket closure.

On a Socket we have:

1. Shutdown

2. Disconnect

3. Close

I am far from clear on what order to call these or whether each of them need to be called.

Consider a server Socket that is connected and has been receiving data async, all working fine.

Now one of the messages sent by client is a "disconnect" message (meaning client is telling server it will soon close it's own client socket, with a reason code etc).

When server gets this message it calls:




At the time this code runs in server, the client has not yet closed or shutdown it's own socket.

The server's call to Shutdown returns right away, but the next call to Disconnect hangs for several minutes.

It eventually comes back and the Close gets called and returns right away too.

Why does Disconnect hang?

Is it perhaps because the Socket was created by Accept and "only" the original client app can initiate this?

If the client sends the disconnect message and then immediately closes it's socket, this might trigger the network exception handler in the server that

Advanced Paging GridView with ASP.NET 2.0/3.5

This is an article about advanced paging GridView with ASP.NET 2.0/3.5. All the HTML, CSS, JavaScript it needs have been embedded into the WizardGridView.dll.

IP Address Blocking or Restriction in SQL Server

"is it possible to block connections to SQL Server based on IP address". As far as now there is no official way in SQL Server to block the connections in SQL Server based on IP address. However this can be done from the OS end, we have the following three options available, refer HERE for more.

.RRAS IP Filter

my ip address

IP Tejji answers question like what is my ip address? find my ip addresss? detect my ip address? Best part is it also determines your local ip address as well as mac address. Further if you keen on browser specification and details regarding browser capabilities can also be found. It also help you see your geographic location. Other details that are available are Latitude, Longitude, timezone, country, region & city. In short it is one-stop-shop for very rich details about your IP and related information.

InfoPath 2010 cannot connect to SharePoint 2010

You have installed Office 2010 beta and you are trying to connect to SharePoint 2010 from InfoPath but you get an error

could somebody give me example how I can connect to database only once if I use many models in contr


I use in my ASP.NET MVC application repository pattern and I use in controller for example 3 models:

   namespace MvcApplication1.Controllers  
        public class HomepageController : Controller  
            private IWebsitesRepository _repository_websites = new WebsitesRepository();  
            private IFirmRepository _repository_firm = new FirmRepository();  
            private IPhotosRepository _repository_photos = new PhotosRepository();  

In WebsiteRepozitory, FirmRepository and PhotosRepository classes I have:

Database1Entities _entities = new Database1Entities();

So I have 3 connections to database ? Is it wrong ? How can I solve it ?

A Challenging Question for Advanced user....


Using  dot net How will you release .exe applicattion for 1000 clients.this question was asked by manager but i could not answer him.tell me if you can!!!

SOA Tips: Address Scalability Bottlenecks with Distributed Caching


SOA makes application scalability easier, but getting the best performance out of your SOA means paying close attention to the details. We'll give you some tips for coding your app more effectively and using distributed caching to remove data access bottlenecks.

Iqbal Khan

MSDN Magazine June 2010

Advanced Basics: The ObservableCollection Class


Ken Getz shows how the CollectionChanged event lets you reflect changes to your underlying data source in your bound data controls.

Ken Getz

MSDN Magazine December 2008

Advanced WPF: Understanding Routed Events And Commands In WPF


See how routed events and routed commands in Windows Presentation Foundation form the basis for communication between the parts of your UI.

Brian Noyes

MSDN Magazine September 2008

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend