Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Firewall HELP

Firewall HELP

Scheduled Pinned Locked Moved Visual Basic
csharphelptutorialquestionlounge
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zoodayz
    wrote on last edited by
    #1

    Ok this is my first post here. So Im admitting im a new bee ok How would I allow my app to run behind a Firewall and NAT???? I am not able to turn it off and I fell others sould not have to also or port forward but lets say with a code like this as a example I got from here Also how about set it up to use random port would that have to do with.. Private Shared port As Integer = 44 ???? Thank you for any help ZoodayZ... Imports System Imports System.Net Imports System.Net.Sockets Imports System.Text Public Class StateObject Public workSocket As Socket = Nothing Public BufferSize As Integer = 32767 Public buffer(32767) As Byte Public sb As New StringBuilder() End Class Public Class SocketsClient Public Event onConnect() Public Event onError(ByVal Description As String) Public Event onDataArrival(ByVal Data As Byte(), ByVal TotalBytes As Integer) Public Event onDisconnect() Public Event onSendComplete(ByVal DataSize As Integer) Private Shared response As [String] = [String].Empty Private Shared port As Integer = 44 Private Shared ipHostInfo As IPHostEntry = Dns.Resolve("localhost") Private Shared ipAddress As ipAddress = ipHostInfo.AddressList(0) Private Shared client As New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) Public Sub Connect(ByVal RemoteHostName As String, ByVal RemotePort As Integer) Try client = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) port = RemotePort ipHostInfo = Dns.Resolve(RemoteHostName) ipAddress = ipHostInfo.AddressList(0) Dim remoteEP As New IPEndPoint(ipAddress, port) client.BeginConnect(remoteEP, AddressOf sockConnected, client) Catch RaiseEvent onError(Err.Description) Exit Sub End Try End Sub Public Sub SendData(ByVal Data() As Byte) Try Dim byteData As Byte() = Data client.BeginSend(byteData, 0, byteData.Length, 0, AddressOf sockSendEnd, client) Catch RaiseEvent onError(Err.Description) Exit Sub End Try End Sub Public Sub Disconnect() Try client.Shutdown(SocketShutdown.Both) Catch End Try client.Close() End Sub Public Function StringToBytes(ByVal Data As String) As Byte() StringToBytes = System.Text.ASCIIEncoding.ASCII.GetByt

    D 1 Reply Last reply
    0
    • Z zoodayz

      Ok this is my first post here. So Im admitting im a new bee ok How would I allow my app to run behind a Firewall and NAT???? I am not able to turn it off and I fell others sould not have to also or port forward but lets say with a code like this as a example I got from here Also how about set it up to use random port would that have to do with.. Private Shared port As Integer = 44 ???? Thank you for any help ZoodayZ... Imports System Imports System.Net Imports System.Net.Sockets Imports System.Text Public Class StateObject Public workSocket As Socket = Nothing Public BufferSize As Integer = 32767 Public buffer(32767) As Byte Public sb As New StringBuilder() End Class Public Class SocketsClient Public Event onConnect() Public Event onError(ByVal Description As String) Public Event onDataArrival(ByVal Data As Byte(), ByVal TotalBytes As Integer) Public Event onDisconnect() Public Event onSendComplete(ByVal DataSize As Integer) Private Shared response As [String] = [String].Empty Private Shared port As Integer = 44 Private Shared ipHostInfo As IPHostEntry = Dns.Resolve("localhost") Private Shared ipAddress As ipAddress = ipHostInfo.AddressList(0) Private Shared client As New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) Public Sub Connect(ByVal RemoteHostName As String, ByVal RemotePort As Integer) Try client = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) port = RemotePort ipHostInfo = Dns.Resolve(RemoteHostName) ipAddress = ipHostInfo.AddressList(0) Dim remoteEP As New IPEndPoint(ipAddress, port) client.BeginConnect(remoteEP, AddressOf sockConnected, client) Catch RaiseEvent onError(Err.Description) Exit Sub End Try End Sub Public Sub SendData(ByVal Data() As Byte) Try Dim byteData As Byte() = Data client.BeginSend(byteData, 0, byteData.Length, 0, AddressOf sockSendEnd, client) Catch RaiseEvent onError(Err.Description) Exit Sub End Try End Sub Public Sub Disconnect() Try client.Shutdown(SocketShutdown.Both) Catch End Try client.Close() End Sub Public Function StringToBytes(ByVal Data As String) As Byte() StringToBytes = System.Text.ASCIIEncoding.ASCII.GetByt

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      zoodayz wrote: How would I allow my app to run behind a Firewall and NAT???? I am not able to turn it off and I fell others sould not have to also or port forward but lets say with a code like this as a example I got from here Also how about set it up to use random port would that have to do with.. Private Shared port As Integer = 44 ???? Are you telling us that the code you included in your post is the server running behind the Firewall/NAT? If so, then you MUST use port forwarding to get to the server from the WAN side of your router. Since there is no direct IP route between the Internet and your local network, the router must be told what ports on the WAN side of the router to forward to which server (IP and port) on the local side. Therefore, you can't use a random port number, unless your app is going to reconfigure the router every time the port number changes. RageInTheMachine9532

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups