I need a bit of help converting this section of VB.NET Code to C#.NET,any help will be appreciated i'm still learning alot and adjusting to the C# Syntex...
Here is the VB.NET Section::
Private
Sub Socket_DataArrival(ByVal eventSender As System.Object, ByVal eventArgs As AxMSWinsockLib.DMSWinsockControlEvents_DataArrivalEvent) Handles Socket.DataArrival
Dim Index As Short = Socket.GetIndex(eventSender)
Socket(Index).GetData(Buffer(Index))
Debug.Print(Buffer(Index))
If Mid(Buffer(Index), 12, 1) = "W" Then
Sessionkey(Index) = Mid(Buffer(Index), 17, 4)
ChallengeString(Index) = Mid(Buffer(Index), 30 + Len(ClientID(Index)), Len(Buffer(Index)) - 29)
ChallengeString(Index) = Replace(ChallengeString(Index),
"?13?1?", "")
Call GetStrings(ClientID(Index), Password(Index), ChallengeString(Index), Crypt1(Index), Crypt2(Index), 1)
Socket(Index).SendData(Login(ClientID(Index), Crypt1(Index), Crypt2(Index), Sessionkey(Index)))
ElseIf Mid(Buffer(Index), 12, 1) = "T" Then
statz.Items.Item(1).Text = ClientID(Index) &
""
Socket(Index).Close()
ElseIf Mid(Buffer(Index), 12, 1) = "U" Then
ListView1.Items.Item(Index).SubItems.Add(1)
Sessionkey(Index) = Mid(Buffer(Index), 17, 4)
statz.Items.Item(2).Text =
CStr(CDbl(statz.Items.Item(2).Text) + 1)
statz.Items.Item(1).Text =
"Status: " & ClientID(Index) & ""
End If
End SubNow here is the Section of C# that i have Translated over,but their are a few sections that might be wrong.And is currently giving me some problems...I havent Completely Moved over that Entire Block of VB.NET to C#,I have stopped at the Socket(Index).SendData part...C# Code Block::
private
void Socket_DataArrival(object sender, EventArgs e)
{
short index;
newsock.Receive(buffer, 0,
SocketFlags.None);
System.Diagnostics.
Debug.Print(LoginMod.LoginMod.Buffer[index]);
if (String.Format(LoginMod.LoginMod.Buffer[index], 12, 1) == "W")
LoginMod.
LoginMod.SessionKey[index] = String.Format("{17}, {4}", LoginMod.LoginMod.Buffer[index]);
LoginMod.
LoginMod.ChallengeString[index] = String.Format("{30},{4}", LoginMod.LoginMod.Buffer[index],
Convert.ToChar(LoginMod.LoginMod.ClientID[index]),
Convert.ToChar(Convert.ToByte(LoginMod.LoginMod.Buffer[index]) - 29));
LoginMod.
LoginMod.ChallengeString[index] = String.Format(LoginMod.LoginMod.ChallengeString[index], "?13?1?", "");
LoginMod.
LoginMod.GetStrings(); /*This Section for the Call GetStrings in VB.NET*/
string Login = LoginMod.LoginMod.ClientID[index];
string Crypt1 = LoginMod.LoginMod.Crypt1[index];
string Crypt2 = LoginMod.LoginMod.Crypt2[index];
string SessionKey = LoginMod.LoginMod.Password[index];
int mode = 1;
newsock.Send(LoginMod.
LoginMod.Login(ref ClientID, ref Crypt1, ref Crypt2, ref SessionKey));Now everything above here in C# like the GetStrings,Crypt1 Etc all exist in the LoginMod.cs.The LoginMod.LoginMod.GetStrings() when i put information in their ,only parts that show up in the intelli-sence is ClientID and Password..Nothing Else Example
Str1,Str2,Crypt1,Crypt2,SessionKey Etc...
Last Section that giving me a bit of trouble is the newsock.Send() "Error: Cannot Convert String to byte[]"...This could be Caused because of this section of code::
private
void Socket_ConnectionEvent(object sender, EventArgs e)
{
byte[] ClientID = new byte[1024];
newsock.Send(ClientID, ClientID.Length,
SocketFlags.None);
}
Translasted again from VB.NET::
Private Sub Socket_ConnectEvent(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Socket.ConnectEvent
Dim Index As Short = Socket.GetIndex(eventSender)
Socket(Index).SendData(Data(ClientID(Index)))
End Sub
The ClientID is Declared in 2 Areas 1: on the Form as: public string ClientID
2: on the LoginMod.cs as: public static string[] ClientID = new string [1001];