|
-
Jul 13th, 2006, 04:51 PM
#1
Thread Starter
Hyperactive Member
[2.0] Need some Socket Help
Ok this is what i have for Code than i'll explain the problem i'm having:
VB Code:
using System;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Runtime;
using System.Net;
using Microsoft.VisualBasic;
using System.Net.Sockets;
using System.Collections;
namespace TestClient
{
public partial class TestClient : Form
{
ColumnHeader Header = new ColumnHeader();
ListViewItem Item = new ListViewItem();
ArrayList socketList = new ArrayList(5);
Socket newsock = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
public YahKiller()
{
InitializeComponent();
}
private void Timer1_Tick(System.Object eventSender, System.EventArgs eventArgs)
{
short i = 0;
for (i = 0; i <= System.Convert.ToInt16(double.Parse(ServerList.Text) - 1); i++)
{
PacketsLabel.Text = System.Convert.ToString(double.Parse(PacketsLabel.Text) + 1);
if (newsock(i).Connected == newsock_ConnectEvent(eventSender, eventArgs)) /* this is the line of code i'm having some trouble with*/
{
string transTemp9 = LoginMod.ClientID[i];
string transTemp10 = (backup.Text);
newsock.SendFile(testfile.PM(ref transTemp9, ref transTemp10));
}
}
i = System.Convert.ToInt16(i + 1);
}
The issue i'm having is with : if (newsock(i).Connected == its the newsock that is giving me the problem,any ideas on the correction of this section of code will be appreciated...Thxs in Advance
Here is the Error:
Error 26 'TestClient.TestClient.newsock' is a 'field' but is used like a 'method'
-
Jul 13th, 2006, 05:00 PM
#2
Re: [2.0] Need some Socket Help
You've got some things mixed up:
1) newsocket is a Socket, not an array of anything, so the parentheses are going to cause a problem.
2) even if newsocket were an array, in c# the array indexer is the square brackets: array[n]
3) It looks like you're trying to assign an event. If you're not, you can ignore this and #4 you assign events by using the += operator and an appropriate delegate:
something.SomeEvent += new EventHandler(myEventHandler)
4) Connected is not an event, it's a boolean property.
Perhaps you meant simply "newsocket" or "((Socket)socketList[i])"?
Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.
-
Jul 13th, 2006, 05:00 PM
#3
Re: [2.0] Need some Socket Help
Firstly, 'newsock' is a Socket, so it has no indexer (equivalent to the default property in VB) so you cannot index it like that. Secondly, if you could index it you'd have to use square brackets, not parentheses. I'm guessing that you mean "socketList[i]", not "newsock(i)".
-
Jul 13th, 2006, 05:01 PM
#4
Re: [2.0] Need some Socket Help
Shazam! Sunburnt's answer was better though.
-
Jul 13th, 2006, 05:22 PM
#5
Thread Starter
Hyperactive Member
Re: [2.0] Need some Socket Help
Is their a way for me to get VS 2005 to open VB6 like maybe installing the VB6 Runtime ,something like that...So i can translate the VB6 to .NET manually,the Convert Feature in VS 2005 just isnt that good..
Tends to mess stuff up all the time..lol really dont want to Re Install Visual Basic 6 Program with VS 2005 installed on the same machine..
Last edited by Rattlerr; Jul 13th, 2006 at 05:29 PM.
-
Jul 13th, 2006, 05:42 PM
#6
Thread Starter
Hyperactive Member
Re: [2.0] Need some Socket Help
But here is the VB6 to .NET upgrade Code:
VB Code:
Private Sub Timer1_Tick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Timer1.Tick
Dim i As Short
For i = 0 To CDbl(ClientList.Text) - 1
PacketsLabel.Text = CStr(CDbl(PacketsLabel.Text) + 1)
'UPGRADE_NOTE: State was upgraded to CtlState. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
If Socket(i).CtlState = MSWinsockLib.StateConstants.sckConnected Then
Socket(i).SendData(PM(ClientID(i), (Server.Text)))
End If
Next i
i = i + 1
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|