![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
You can't do that. You are running your code on the main thread. That means the code is running in a sequence. Line 1 runs before line 2 and so on. Please move your code to after the : // TODO: Add any constructor code after InitializeComponent call I would recommend a J# book: http://www.microsoft.com/learning/bo...t/vjsharp.net/ http://www.microsoft.com/mspress/books/5834.asp The example: package WindowsApplication3; import System.Drawing.*; import System.Collections.*; import System.ComponentModel.*; import System.Windows.Forms.*; import System.Data.*; /** * Summary description for Form1. */ public class Form1 extends System.Windows.Forms.Form { /** * Required designer variable. */ private System.ComponentModel.Container components = null; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // // YOUR CODE HERE server=new ServerSocket(15); nextClient=server.accept(); txtConnection.set_Text("Kuruldu!"); } /** * Clean up any resources being used. */ protected void Dispose(boolean disposing) { if (disposing) { if (components != null) { components.Dispose(); } } super.Dispose(disposing); } #region Windows Form Designer generated code /** * Required method for Designer support - do not modify * the contents of this method with the code editor. */ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.set_Size(new System.Drawing.Size(300,300)); this.set_Text("Form1"); } #endregion /** * The main entry point for the application. */ /** @attribute System.STAThread() */ public static void main(String[] args) { Application.Run(new Form1()); } } Regards, Lars-Inge Tønnessen |
#3
| |||
| |||
|
|
Do you know threads? thinking the same example; suppose that both client and server windows forms are on each of the screens, and the connection is established. The server listens for clients. A client "drive" the connection cycle The server will only handle requests from the client. Servers do not connect to clients. There are no problem to first open a connection from a client to a server and let them switch roles. You do that with a read/write protocol, or by using two socket connections (one from the client to the server, and an other from the server (that acts as a new client) to the client (that acts as a server). how will i trigger the client side, when i fill in a textfield and click on the submit button on the server side? because client must get the inputstream, how? For a socket code example please see one of my previous socket reply: http://www.codecomments.com/forum295/message407079.html Application.Run(new Form1()); You should not do anything at all here. The solution to a blocking socket connection and a user interface are threads. The solution for the "Application.Run()" thing is also threads. The question is, do you know what a thread is (I must know this before I can provide more help) ? Best regards, Lars-Inge Tønnessen |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |