Firewall HELP
-
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
-
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
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