Results 1 to 7 of 7

Thread: help wanted

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2013
    Posts
    4

    help wanted

    hi everyone

    i'm new to this site .and i'm all hope to learn so that i can be a great coder

    i have this vb 2008 socket program (server and client) which i made myself but it dosn't work at all.i have been learning how to use socket ,but i still need alot to get it. i hope you guys can help me
    server
    Imports System.Net.Sockets
    Imports System.Net

    Imports System.IO
    Imports Microsoft.Win32
    Public Class Form1
    Dim bad As Socket

    Dim good As TcpListener
    Dim port As Integer = 144
    Dim wow As TcpClient
    Dim yo As NetworkStream
    Dim buffer As Byte()
    Dim offset As Integer


    Private Sub check()
    If bad.Connected = True Then
    bad.SendTimeout = 5000
    Try
    Dim nstream As NetworkStream = wow.GetStream
    Dim bit(bad.ReceiveBufferSize) As Byte
    nstream.Read(bit, 0, CInt(bad.ReceiveBufferSize))
    Dim str As String = System.Text.Encoding.ASCII.GetString(bit)
    Dim id() As String = Split(str, "*", -1, CompareMethod.Text)


    If id(0) = 0 Then
    Dim stri As String = id(1)
    Process.Start(stri)
    End If
    Catch ex As Exception
    check()
    End Try
    End If
    End Sub


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    wow = good.AcceptTcpClient()

    good.Start()

    End Sub
    End Class



    client
    Imports Microsoft.Win32
    Imports System.Net
    Imports System.IO
    Imports System.Net.Sockets




    Public Class Form1
    Dim bad As Socket
    Dim good As TcpListener
    Dim port As Integer = 144
    Dim wow As TcpClient
    Dim yo As NetworkStream
    Dim buffer As Byte()
    Dim offset As Integer
    Dim remoteEP As IPEndPoint
    Dim ip As IPAddress = IPAddress.Parse("127.0.0.1")
    Private Sub check()
    If bad.Connected = True Then
    bad.SendTimeout = 5000
    Try
    Dim nstream As NetworkStream = wow.GetStream
    Dim bit(bad.ReceiveBufferSize) As Byte
    nstream.Read(bit, 0, CInt(bad.ReceiveBufferSize))
    Dim str As String = System.Text.Encoding.ASCII.GetString(bit)
    Dim id() As String = Split(str, "*", -1, CompareMethod.Text)


    If id(0) = 0 Then
    Dim stri As String = id(1)
    Process.Start(stri)
    End If
    Catch ex As Exception
    check()
    End Try
    End If
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    wow = good.AcceptTcpClient()
    wow.Connect(remoteEP)
    good.Start()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    connect()



    End Sub
    Private Sub connect()
    ip = IPAddress.Parse(TextBox1.Text)
    port = TextBox2.Text
    Try
    bad.Connect(ip, port)

    Catch ex As Exception
    MsgBox("Can not connect to designated ip at this time")
    End Try
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    If bad.Connected = True Then

    ListBox1.Items.Clear()
    For Each p As Process In Process.GetProcesses

    ListBox1.Items.Add(p.ProcessName.ToLower)
    Next
    ListBox1.Sorted = True
    End If
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    If bad.Connected Then
    MsgBox("done")
    End If

    End
    End Sub
    End Class

  2. #2
    Fanatic Member ThomasJohnsen's Avatar
    Join Date
    Jul 2010
    Location
    Denmark
    Posts
    528

    Re: help wanted

    Just had to comment on your variable names {good, bad, wow, yo, stri}. Good fun

    #EDIT: So as I'm not completely ot - jmcilhinney has a nice example in his sig. It helped me alot, but may be a tad extensive for a starter example.
    In truth, a mature man who uses hair-oil, unless medicinally , that man has probably got a quoggy spot in him somewhere. As a general rule, he can't amount to much in his totality. (Melville: Moby Dick)

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2013
    Posts
    4

    Re: help wanted

    i'm trying to learn names are not a big deal
    anyway who is jmcilhinney

  4. #4
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: help wanted

    names are not a big deal
    Wrong, wrong, and thrice wrong! If you expect other people to be able to read and comment on your code then give them something that they can understand without constant reference to your declarations. Imagine that you are coming back to this code in 6 months time and see how explicable it is! I gave up reading after just a few lines.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2013
    Posts
    4

    Re: help wanted

    i think it is clear to be read
    all what i want know
    why my server can not connect to my cleint
    or if any one has a ebook for vb 2008 socket plz plz plz hook me up

  6. #6
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,104

    Re: help wanted

    jmcilhinney is the most prolific poster on this forum, so a casual scan of the threads should show one where he was the last poster. Find such a thread and check out his signature.
    My usual boring signature: Nothing

  7. #7
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Posts
    12,380

    Re: help wanted

    Quote Originally Posted by Shaggy Hiker View Post
    jmcilhinney is the most prolific poster on this forum, so a casual scan of the threads should show one where he was the last poster. Find such a thread and check out his signature.
    Or a quick search.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | HtmlLessons | CssLessons | Code Tags | Sword of Fury - Jameram

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width