hey guys
any one can help me plz...................
Win or console App in C# ,as soo As possible ..............Tanx
Write a simple TCP program for a server that accepts lines of input from a
client and prints the lines onto the server's standard output.
Compile and execute your program.
On any other machine that contains a Web browser, set the proxy
server in the browser to the host that is running your server program; also configure
the port number appropriately. Your browser should now send its GET
request messages to your server, and your server should display the messages
on its standard output. Use this platform to determine whether your browser
generates conditional GET messages for objects that are locally cached.
4 replies to this topic
#1
Posted 22 January 2012 - 12:29 PM
|
|
|
#2
Posted 23 January 2012 - 07:19 AM
Can you post the code that you already have done so far and show us where you're having trouble please?
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid
#3
Posted 24 January 2012 - 06:28 AM
yep .. why not . :D
it's in server part:
and this is about client one:
and my problem that causes dosent work is about the port number , every port that i used to ,even if i import it to firewall exception but again it doseint work ..!
any idea???
it's in server part:
public partial class Form1 : Form
{
Socket sock1;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string name = Dns.GetHostName();
IPAddress ip = Dns.GetHostByName(name).AddressList[0]; //saving ip
MessageBox.Show(ip.ToString());
IPEndPoint ipe = new IPEndPoint(ip,xxxx); //saving ip &port number
Socket sock1 = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp); //installing a new socket!
sock1.Bind(ipe); //making bind function by nameing it ipendpoint!!!
sock1.Listen(5); //number of syste's it's going to listen to....
sock1 = sock1.Accept(); //accept's things.....
byte[] data=new byte[50000]; //makeing array to get data from client!!!
sock1.Receive(data); //receive the"data" from client!
textBox1.AppendText(Encoding.ASCII.GetString(data)); //
}
}
}
and this is about client one:
namespace client
{
public partial class Form1 : Form
{
Socket sock1;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string name = Dns.GetHostName(); //get ip
IPAddress ip = Dns.GetHostByName(name).AddressList[0]; //save ip on var
IPEndPoint ipe = new IPEndPoint(ip,xxxx);// save ip & port number!
sock1 = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp); //installing new socket!
sock1.Connect(ipe); //try to connect with ipendpoint( port must be same as server!)
MessageBox.Show("Connection Reliable.");
}
private void button2_Click(object sender, EventArgs e)
{
string data = textBox1.Text; //fill's data with text box 1!
sock1.Send(Encoding.ASCII.GetBytes(data)); //encode & send's data to server!!!
}
}
}
and my problem that causes dosent work is about the port number , every port that i used to ,even if i import it to firewall exception but again it doseint work ..!
any idea???
#4
Posted 24 January 2012 - 11:21 AM
I'm not super fluent in network programming in C#, perhaps someone else who is can double check your code better than I can. But I don't immediately see anything alarming. What exactly is happening? Are you getting an exception? Is the code blocking on any certain methods and not progressing? What exactly is happening that is causing it not to work?
What port numbers have you been using? I don't believe Windows will allow binding to ports under 1023 under normal user privileges. But if you're using one of the higher ports, you shouldn't have a problem.
Have you tried turning the firewall completely off to see if that makes a difference? (That would indicate if there is a problem with your port configuration in the firewall.)
What port numbers have you been using? I don't believe Windows will allow binding to ports under 1023 under normal user privileges. But if you're using one of the higher ports, you shouldn't have a problem.
Have you tried turning the firewall completely off to see if that makes a difference? (That would indicate if there is a problem with your port configuration in the firewall.)
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid
#5
Posted 10 April 2012 - 08:40 PM
I just tested the code with port number to 7799 and it worked here. I set the LAN proxy settings to port 7799 and the ip the server listened to.

Then I opened a page in browser and I got text "Chrome/18.0.1025.152 Safari/535.19" in server in the text box.
Then I opened a page in browser and I got text "Chrome/18.0.1025.152 Safari/535.19" in server in the text box.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top










