Click here to Skip to main content
15,902,189 members
Home / Discussions / C#
   

C#

 
AnswerRe: Binary to hex Conversion ? Pin
Luc Pattyn11-Oct-10 1:13
sitebuilderLuc Pattyn11-Oct-10 1:13 
QuestionProgram hangs... Pin
ayandelhi10-Oct-10 19:33
ayandelhi10-Oct-10 19:33 
AnswerRe: Program hangs... Pin
ScottM110-Oct-10 20:55
ScottM110-Oct-10 20:55 
AnswerRe: Program hangs... Pin
Rajesh Anuhya10-Oct-10 21:37
professionalRajesh Anuhya10-Oct-10 21:37 
AnswerRe: Program hangs... Pin
Harvey Saayman11-Oct-10 1:07
Harvey Saayman11-Oct-10 1:07 
AnswerRe: Program hangs... Pin
Luc Pattyn11-Oct-10 1:17
sitebuilderLuc Pattyn11-Oct-10 1:17 
AnswerRe: Program hangs... Pin
#realJSOP11-Oct-10 2:38
professional#realJSOP11-Oct-10 2:38 
AnswerCode... Pin
ayandelhi11-Oct-10 4:44
ayandelhi11-Oct-10 4:44 
This is the complete source code for my server side program... on clicking the button it calls func conn_man.. on clicking it this program hangs...

b4 clicking it.. the program is responding n i can move it resize it n stuff.. but after the button is clicked its not responding.. plz.. tell me how to get it working..

on receiving the connection from client it searches for a free port on the server it self.. when found it sends the client the free port to connect to[ function route does it]..

master_slave is another form which is called on accepting a connection from client
<pre>
namespace master
{
public partial class main_form : Form
{
public int port;
public main_form()
{
InitializeComponent();
activity_win.AppendText("Master On...");
}

public void conn_man()
{
try
{
//activity_win.AppendText("In conn_man...");
IPAddress ipAd = IPAddress.Parse("192.168.1.2");
// use local m/c IP address, and
// use the same in the client
/* Initializes the Listener */
TcpListener listener = new TcpListener(ipAd, 5000);
/* Start Listeneting at the specified port */
listener.Start();
activity_win.AppendText("\r\nThe server is running at port 5000...");
activity_win.AppendText("\r\nThe local End point is :" + listener.LocalEndpoint);
activity_win.AppendText("\r\nWaiting for a connection.....");
Socket s = listener.AcceptSocket();
activity_win.AppendText("\r\nConnection accepted from " + s.RemoteEndPoint);
byte[] b = new byte[100];
int k = s.Receive(b);
activity_win.AppendText("Recieved...");
activity_win.AppendText(ASCIIEncoding.ASCII.GetString(b));
if (route(5000) == 0)
{
activity_win.AppendText("No port free");
ASCIIEncoding asen = new ASCIIEncoding();
s.Send(asen.GetBytes("Busy"));
}
else
{
port = route(5000);
new master_slave(port);
ASCIIEncoding asen = new ASCIIEncoding();
s.Send(asen.GetBytes("Port " + port.ToString()));
}
/* clean up */
s.Close();
}
catch (Exception e)
{
activity_win.AppendText("Error..... " + e.StackTrace);
}
}

public int route(int port)
{
try
{
TcpClient scnr = new TcpClient("localhost", port);
return port;
}
catch (Exception e)
{
activity_win.AppendText(e.ToString());
port += 10;
route(port);
return 0;
}
}

private void Begin_Click(object sender, EventArgs e)
{
conn_man();
}
}
}
</pre>
GeneralRe: Code... Pin
ayandelhi11-Oct-10 6:25
ayandelhi11-Oct-10 6:25 
GeneralRe: Code... Pin
Pete O'Hanlon11-Oct-10 6:43
mvePete O'Hanlon11-Oct-10 6:43 
GeneralRe: Code... Pin
ayandelhi11-Oct-10 7:07
ayandelhi11-Oct-10 7:07 
QuestionAccess the ConfigSection of specified config file Pin
AndieDu10-Oct-10 18:59
AndieDu10-Oct-10 18:59 
QuestionCancel on ThreadPool queued executions? Pin
devvvy10-Oct-10 17:47
devvvy10-Oct-10 17:47 
AnswerRe: Cancel on ThreadPool queued executions? Pin
Harvey Saayman10-Oct-10 21:29
Harvey Saayman10-Oct-10 21:29 
GeneralRe: Cancel on ThreadPool queued executions? Pin
devvvy11-Oct-10 2:49
devvvy11-Oct-10 2:49 
GeneralRe: Cancel on ThreadPool queued executions? Pin
Harvey Saayman11-Oct-10 2:52
Harvey Saayman11-Oct-10 2:52 
AnswerRe: Cancel on ThreadPool queued executions? Pin
Luc Pattyn11-Oct-10 1:23
sitebuilderLuc Pattyn11-Oct-10 1:23 
GeneralRe: Cancel on ThreadPool queued executions? Pin
devvvy11-Oct-10 3:03
devvvy11-Oct-10 3:03 
GeneralRe: Cancel on ThreadPool queued executions? Pin
Luc Pattyn11-Oct-10 3:15
sitebuilderLuc Pattyn11-Oct-10 3:15 
QuestionSeperate conversion functions or 1 overloaded function? Pin
stephen.darling10-Oct-10 3:23
stephen.darling10-Oct-10 3:23 
AnswerRe: Seperate conversion functions or 1 overloaded function? Pin
PIEBALDconsult10-Oct-10 4:18
mvePIEBALDconsult10-Oct-10 4:18 
AnswerRe: Seperate conversion functions or 1 overloaded function? Pin
Abhinav S10-Oct-10 6:04
Abhinav S10-Oct-10 6:04 
GeneralRe: Seperate conversion functions or 1 overloaded function? Pin
stephen.darling10-Oct-10 7:22
stephen.darling10-Oct-10 7:22 
GeneralRe: Seperate conversion functions or 1 overloaded function? [modified] Pin
Not Active10-Oct-10 9:28
mentorNot Active10-Oct-10 9:28 
AnswerRe: Seperate conversion functions or 1 overloaded function? Pin
Eddy Vluggen10-Oct-10 11:34
professionalEddy Vluggen10-Oct-10 11:34 

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.