Author | Message |
---|
NeiSep Ametuar Posts: 93
| Hi there people well im new to delphi i have read trow some source and so on and read about the socket but im littlebit unsure if this is the right thing to use check out the code:
Code: | unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ScktComp; type TForm1 = class(TForm) ClientSocket1: TClientSocket; Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin ClientSocket1.Active; end; procedure TForm1.Button2Click(Sender: TObject); begin ClientSocket1.Close; end; end. |
|
Meka][Meka Unstopable Posts: 700
|
Code: | procedure TForm1.Button1Click(Sender: TObject); begin ClientSocket1.Active := True; end; procedure TForm1.Button2Click(Sender: TObject); begin ClientSocket1.Active := False; end; |
|
NeiSep Ametuar Posts: 93
| ow lol i forgot that lol well my softare looks like that. But i still got connection problem i tried everything ClientSocket1.Active and Close to nothing seems to work.
|
Meka][Meka Unstopable Posts: 700
| wait, your making a server?? the hublist server? if so, then you shudnt be using client sockets
|
NeiSep Ametuar Posts: 93
| ok check this code:
Code: | procedure TForm1.Button1Click(Sender: TObject); begin button1.Enabled := False; ClientSocket1.Address := edit7.Text; ClientSocket1.Host := edit7.Text; ClientSocket1.Port := strToint(edit8.Text); ClientSocket1.Active := true; Shape1.Brush.Color := clLime; memo3.Lines.Add(''+edit1.text+''); button2.Enabled := True; end; procedure TForm1.Button2Click(Sender: TObject); begin button1.Enabled := True; ProgressBar1.Max := 100; //ClientSocket1.Socket.Close; ClientSocket1.Active := False; ProgressBar1.StepBy(50); Shape1.Brush.Color := clRed; ProgressBar1.StepBy(50); Memo1.Lines.Add('Disconnected'); ProgressBar1.StepBy(-50); Sleep(1000); ProgressBar1.StepBy(-50); memo3.text := ''; button2.Enabled := False; end; | Whatever i write i still get connection error This is for a bot i making not for any servers or so..
|
Meka][Meka Unstopable Posts: 700
| first off.... your code is very bad
Code: | procedure TForm1.Button2Click(Sender: TObject); begin button1.Enabled := True; ProgressBar1.Max := 100; //ClientSocket1.Socket.Close; ClientSocket1.Active := False; ProgressBar1.StepBy(50); Shape1.Brush.Color := clRed; ProgressBar1.StepBy(50); Memo1.Lines.Add('Disconnected'); ProgressBar1.StepBy(-50); Sleep(1000); ProgressBar1.StepBy(-50); memo3.text := ''; button2.Enabled := False; end; | why do u also sleep for 1 sec ?? why have disconnected, when ther might have been an error disconnecting or some other misc, such as already disconnected add a disconnect and error event, remove the sleep, and the progessar goes back n forward??? this aint enough to test the prog, and how does it refuse, where is the code returning anything timeout or refused, and such....
|
NeiSep Ametuar Posts: 93
| well i made the sleep becuse i dont want the loading bar to go to quik hehe. and the error code is em let me check. Software caused connection abort Error code: 10053 Have a nice day Well the code i added up there was from a bot of mine i didnt want any more problems so i tought to take code from my bot instead of doing a new app.
|
NeiSep Ametuar Posts: 93
| So there are nobody here that got the same problem? Is it just me that is stupid or what is wrong with me?
|