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

C#

 
GeneralRe: Problem with using "out" in void methods Pin
Not Active7-Oct-09 12:14
mentorNot Active7-Oct-09 12:14 
AnswerRe: Problem with using "out" in void methods Pin
Saksida Bojan7-Oct-09 10:12
Saksida Bojan7-Oct-09 10:12 
Questionweb and window applications that work on one same database file Pin
Djtech017-Oct-09 8:31
Djtech017-Oct-09 8:31 
AnswerRe: web and window applications that work on one same database file Pin
Christian Graus7-Oct-09 10:00
protectorChristian Graus7-Oct-09 10:00 
GeneralRe: web and window applications that work on one same database file Pin
Djtech018-Oct-09 6:53
Djtech018-Oct-09 6:53 
AnswerRe: web and window applications that work on one same database file Pin
Christian Graus7-Oct-09 11:05
protectorChristian Graus7-Oct-09 11:05 
QuestionWhy server doesn't respond? Pin
Aljaz1117-Oct-09 7:46
Aljaz1117-Oct-09 7:46 
AnswerRe: Why server doesn't respond? Pin
Luc Pattyn7-Oct-09 9:05
sitebuilderLuc Pattyn7-Oct-09 9:05 
Hi,

IMO there are a few problems:

1.
Socket socketForClient = tcpListener.AcceptSocket(); is a blocking call, which means it returns only when the connection is established. So the thread will have to wait; as the code seems to be inside a Form's Load handler, that Form will not show nor function as long as you don't have a connection.

2.
the whole if (socketForClient.Connected)... statement sits inside a while loop which has no way to terminate, so your code will never finish the Load handler, your Form will never become alive.

The solution to both problems is to use a separate thread; that way your Form can start, and react to your operations, while the other thread deals with the networking. Handlers running on the GUI thread (such as a Load handler) should never take more than some 30 milliseconds, which basically means all networking should always be performed by some other thread.

Smile | :)

Luc Pattyn

I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages

Local announcement (Antwerp region): Lange Wapper? Neen!


GeneralRe: Why server doesn't respond? Pin
Aljaz1118-Oct-09 0:17
Aljaz1118-Oct-09 0:17 
GeneralRe: Why server doesn't respond? Pin
Luc Pattyn8-Oct-09 1:10
sitebuilderLuc Pattyn8-Oct-09 1:10 
GeneralRe: Why server doesn't respond? [modified] Pin
Aljaz1118-Oct-09 5:31
Aljaz1118-Oct-09 5:31 
GeneralRe: Why server doesn't respond? Pin
Luc Pattyn8-Oct-09 5:49
sitebuilderLuc Pattyn8-Oct-09 5:49 
GeneralRe: Why server doesn't respond? Pin
Aljaz1118-Oct-09 5:55
Aljaz1118-Oct-09 5:55 
QuestionHelp is needed (Urgent) Pin
jashimu7-Oct-09 7:40
jashimu7-Oct-09 7:40 
AnswerRe: Help is needed (Urgent) Pin
EliottA7-Oct-09 9:07
EliottA7-Oct-09 9:07 
QuestionWhat's special with message box? Pin
teknolog1237-Oct-09 6:56
teknolog1237-Oct-09 6:56 
AnswerRe: What's special with message box? Pin
PIEBALDconsult7-Oct-09 7:27
mvePIEBALDconsult7-Oct-09 7:27 
GeneralRe: What's special with message box? [modified] Pin
teknolog1237-Oct-09 7:37
teknolog1237-Oct-09 7:37 
GeneralRe: What's special with message box? Pin
LimitedAtonement7-Oct-09 7:42
LimitedAtonement7-Oct-09 7:42 
GeneralRe: What's special with message box? Pin
teknolog1237-Oct-09 8:09
teknolog1237-Oct-09 8:09 
GeneralRe: What's special with message box? Pin
PIEBALDconsult7-Oct-09 7:42
mvePIEBALDconsult7-Oct-09 7:42 
QuestionAnother method safer than StreamWriter and how can I save the file on another server (asp.net c sharp) Pin
aspkiddy7-Oct-09 6:32
aspkiddy7-Oct-09 6:32 
QuestionCode Readability Poll Pin
LimitedAtonement7-Oct-09 5:57
LimitedAtonement7-Oct-09 5:57 
AnswerRe: Code Readability Poll Pin
Kevin Marois7-Oct-09 6:34
professionalKevin Marois7-Oct-09 6:34 
GeneralRe: Code Readability Poll Pin
N a v a n e e t h7-Oct-09 7:38
N a v a n e e t h7-Oct-09 7:38 

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.