ProgrammersHell
Programmer
I could really use some help controlling the IrDA port on my laptop. I want to create some kind of server that can accept connections from PocketPC's. I cant use the IrDA Client and IrDALister classes, because they only excist in the .Net Compact framework. This is what i have so far:
using System;
using System.Net;
using System.Net.Sockets;
class TestIR
{
//serv is the accepting socket
private Socket serv, conn;
EndPoint ep, irdaEp;
public TestIR()
{
try
{
serv = new Socket(AddressFamily.Irda, SocketType.Stream, ProtocolType.Unspecified);
ep = new IPEndPoint(0,0);
irdaEp = (EndPoint)ep.Create(new SocketAddress(AddressFamily.Irda));
serv.Bind(ep);
conn = serv.Accept();
Console.WriteLine("Availability: {0}",conn.Available);
}catch(SocketException e)
{
Console.WriteLine("Error {0} found with message {1}",e.ErrorCode, e.Message);
}
}
public static void Main()
{
TestIR ir = new TestIR();
}
}
The problem is that the socket has to be bound to an EndPoint (serv.Bind(ep)). I found out that you cant use an IPEndPoint (gives some kind of pointer error), and IrDAEndPoint isn't available. Also, you cant make an instance of EndPoint (abstract).
In the above code, the error says that i cant create an EndPoint of the Irda AddressFamily with an IPEndPoint.
The only other solution i know is the more low-level WinSock2 programming, but i want to try it in C# first.
I hope someone can help me.
using System;
using System.Net;
using System.Net.Sockets;
class TestIR
{
//serv is the accepting socket
private Socket serv, conn;
EndPoint ep, irdaEp;
public TestIR()
{
try
{
serv = new Socket(AddressFamily.Irda, SocketType.Stream, ProtocolType.Unspecified);
ep = new IPEndPoint(0,0);
irdaEp = (EndPoint)ep.Create(new SocketAddress(AddressFamily.Irda));
serv.Bind(ep);
conn = serv.Accept();
Console.WriteLine("Availability: {0}",conn.Available);
}catch(SocketException e)
{
Console.WriteLine("Error {0} found with message {1}",e.ErrorCode, e.Message);
}
}
public static void Main()
{
TestIR ir = new TestIR();
}
}
The problem is that the socket has to be bound to an EndPoint (serv.Bind(ep)). I found out that you cant use an IPEndPoint (gives some kind of pointer error), and IrDAEndPoint isn't available. Also, you cant make an instance of EndPoint (abstract).
In the above code, the error says that i cant create an EndPoint of the Irda AddressFamily with an IPEndPoint.
The only other solution i know is the more low-level WinSock2 programming, but i want to try it in C# first.
I hope someone can help me.