Click here to Skip to main content
15,891,033 members
Home / Discussions / C#
   

C#

 
QuestionCareer in 2005 + n? Pin
WDI26-May-05 6:30
WDI26-May-05 6:30 
AnswerRe: Career in 2005 + n? Pin
Judah Gabriel Himango26-May-05 7:13
sponsorJudah Gabriel Himango26-May-05 7:13 
AnswerRe: Career in 2005 + n? Pin
Anonymous27-May-05 16:31
Anonymous27-May-05 16:31 
QuestionHow to retrieve Image from access Database Pin
eng.mohamed26-May-05 5:55
eng.mohamed26-May-05 5:55 
AnswerRe: How to retrieve Image from access Database Pin
Judah Gabriel Himango26-May-05 9:13
sponsorJudah Gabriel Himango26-May-05 9:13 
GeneralOdbcDataReader!! Pin
trk_wakil26-May-05 5:04
trk_wakil26-May-05 5:04 
GeneralRe: OdbcDataReader!! Pin
pubududilena26-May-05 19:34
pubududilena26-May-05 19:34 
Generalsocket handling Pin
cyrus10926-May-05 4:49
cyrus10926-May-05 4:49 
I have to make for school a project in C# that does the work of router.
I mean that i have to check on certain ports for an incomming connections and then check if there is a rule made for this port. If there is rule made for this then i have to forward this connection to a certain ip address or block it.
My user interface is done and i even created a service which will do the handling of the connections.
But i am stuck now with how will i forward a connection.
This is some of the function i made:
This is the function to create the socket:
{
LocalSocket = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP);
LocalSocket.Blocking = false;
LocalSocket.Bind(new IPEndPoint(IPAddress.Parse(GetLocalIP()),
LocalRole.GetSourcePort()));
}
after that i call this function:
public void Start()
{
IAsyncResult ar = LocalSocket.BeginReceive(receive_buf_bytes, 0, len_receive_buf, SocketFlags.None, new AsyncCallback(CallReceive), this);
}
and this is the function that should forward the connection but i am not sure how to complete it:
private void CallReceive(IAsyncResult ar)
{
int received_bytes;
received_bytes = LocalSocket.EndReceive(ar);
//Receive(receive_buf_bytes, received_bytes);
if(LocalRole.GetSourceIp() != "0.0.0.0")
{
if(LocalRole.GetSourceIp() == ((IPEndPoint)(LocalSocket.RemoteEndPoint)).Address.ToString())
{

}
Start();
}
Could someone explain me how i should make this function to forward the connection?

thx
cyrus

GeneralRe: socket handling Pin
S. Senthil Kumar26-May-05 5:06
S. Senthil Kumar26-May-05 5:06 
GeneralRe: socket handling Pin
cyrus10926-May-05 5:12
cyrus10926-May-05 5:12 
GeneralRe: socket handling Pin
S. Senthil Kumar26-May-05 6:19
S. Senthil Kumar26-May-05 6:19 
GeneralRe: socket handling Pin
cyrus10926-May-05 10:17
cyrus10926-May-05 10:17 
GeneralHandling Win32 logical palette's in C# Pin
Rahsas26-May-05 3:41
Rahsas26-May-05 3:41 
GeneralWord automation selecting tray Pin
Master_Blaster26-May-05 3:05
Master_Blaster26-May-05 3:05 
GeneralRemoting Q. Pin
Member 199247026-May-05 1:06
Member 199247026-May-05 1:06 
GeneralRe: Remoting Q. Pin
S. Senthil Kumar26-May-05 2:59
S. Senthil Kumar26-May-05 2:59 
GeneralRe: Remoting Q. Pin
Member 199247026-May-05 4:42
Member 199247026-May-05 4:42 
GeneralImplementation in C# Pin
Diego12326-May-05 0:52
Diego12326-May-05 0:52 
GeneralRe: Implementation in C# Pin
Marc Clifton26-May-05 1:04
mvaMarc Clifton26-May-05 1:04 
GeneralRe: Implementation in C# Pin
Colin Angus Mackay26-May-05 1:49
Colin Angus Mackay26-May-05 1:49 
GeneralRe: Implementation in C# Pin
S. Senthil Kumar26-May-05 2:55
S. Senthil Kumar26-May-05 2:55 
GeneralRe: Implementation in C# Pin
Colin Angus Mackay26-May-05 3:16
Colin Angus Mackay26-May-05 3:16 
GeneralRe: Implementation in C# Pin
S. Senthil Kumar26-May-05 4:24
S. Senthil Kumar26-May-05 4:24 
GeneralWhy toolbar buttons doesn't care of CausesValidation Pin
Itanium26-May-05 0:38
Itanium26-May-05 0:38 
GeneralRe: Why toolbar buttons doesn't care of CausesValidation Pin
Luis Alonso Ramos26-May-05 5:12
Luis Alonso Ramos26-May-05 5:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.