Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

P2P Only works on my network?


  • Please log in to reply
16 replies to this topic

#1 Wolfy87

Wolfy87

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:11:47 AM

Posted 14 April 2009 - 01:26 PM

Hi, i have followed a tutorial to make a simple P2P messenger program, here is my code:

Imports System.Net.Sockets
Imports System.Threading
Imports System.IO

Public Class Form1
	Dim Listener As New TcpListener(65535)
	Dim Client As New TcpClient
	Dim Message As String = ""

	Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		Dim ListThread As New Thread(New ThreadStart(AddressOf Listening)) 'Creates the thread
		ListThread.Start() 'Starts the thread
	End Sub

	Private Sub Listening()
		Listener.Start()
	End Sub

	Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
		If Listener.Pending = True Then
			Message = ""
			Client = Listener.AcceptTcpClient()

			Dim Reader As New StreamReader(Client.GetStream())
			While Reader.Peek > -1
				Message = Message + Convert.ToChar(Reader.Read()).ToString
			End While

			MsgBox(Message, MsgBoxStyle.OkOnly)
		End If
	End Sub

	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		Client = New TcpClient("192.168.1.65", 65535)

		Dim Writer As New StreamWriter(Client.GetStream())
		Writer.Write(TextBox1.Text)
		Writer.Flush()
	End Sub

	Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
		Listener.Stop()
	End Sub
End Class

It works if i run it on my computer, it sends to myself but not to my freind, anyone got any ideas?

Thanks alot, Wolfy87.

BC AdBot (Login to Remove)

 


#2 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:11:47 AM

Posted 14 April 2009 - 01:54 PM

It also works from my dad to me by the way.

Thanks, Wolfy87.

#3 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer


  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:04:47 AM

Posted 14 April 2009 - 02:17 PM

Is a firewall running on the other end?

Billy3
Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

#4 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:11:47 AM

Posted 14 April 2009 - 02:23 PM

I've thought of that, diabled BOTH, still nothing, its still being "activly blocked" from the other end

Wolfy87.

#5 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer


  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:04:47 AM

Posted 14 April 2009 - 02:24 PM

Does the person on the other end have a wireless router? Are there multiple computers shared at that location?

Billy3
Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

#6 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:11:47 AM

Posted 14 April 2009 - 02:26 PM

Yes, thats just it, we are all thru the same router, that is why it works, with my freind in another town it fails but here it works, im not really worried about it not working with my dads, its just getting it to send over the web and not just a wireless network.

Wolfy87.

#7 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:11:47 AM

Posted 14 April 2009 - 02:28 PM

Is there some form of different ip i need like a web one, longer and more unique?

#8 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer


  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:04:47 AM

Posted 14 April 2009 - 02:31 PM

You would need to forward the connection inside the router. The NAT (Network Address Translation) which the wireless router employs to share the connection among multiple computers means that you can't have something that directly connects to a computer from outside. Basicallly... when the incoming packet arrives, the router doesn't know to which machine the packet belongs, because no machine has asked for a packet.

More info on NAT here:
http://en.wikipedia.org/wiki/Network_address_translation

This is why commercial services such as Aol Instant Messager and Windows Live rely on external tunneling servers with unique IP addresses. Without a machine running outside of a NAT to perform tunneling, that type of system doesn't work.

Billy3
Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

#9 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:11:47 AM

Posted 14 April 2009 - 03:02 PM

Well how dose FTP fair to this method? What if I had a file on a server and used that as sort of a chat server because my freind has just got that sorted, I know this becuse I as alarmed to find a picture of an orange on my server called from Ashley, would this be a working but slow altitnative?

Thanks, Wolfy87.

#10 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer


  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:04:47 AM

Posted 14 April 2009 - 03:15 PM

FTP requires open ports as well. If he/she was running an FTP server, then the router in question was already configured to allow forwarding.

Billy3
Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

#11 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:11:47 AM

Posted 15 April 2009 - 05:52 AM

So no matter what ftp should work, aslong as i have a port open? although apparently it is verry slow.

#12 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer


  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:04:47 AM

Posted 15 April 2009 - 01:15 PM

If you're going to do all that work you might as well open the port for your chat app directly.

Billy3
Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

#13 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:11:47 AM

Posted 15 April 2009 - 02:56 PM

but we do, there is a port open?... i think

#14 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer


  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:04:47 AM

Posted 15 April 2009 - 07:44 PM

How would I know LOL? :thumbsup:

Connection shouldn't fail if it's opened right....

Billy3
Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

#15 mckooter

mckooter

  • Members
  • 211 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Maine
  • Local time:07:47 AM

Posted 17 April 2009 - 02:46 PM

Yeah Wolfy87

you would need to login to both of your routers admin panel and make sure to open the port, from the looks of it you are using port 65535, so you will need to login and goto port forwarding, and forward that port in the router to your specific internal ip address.

http://portforward.com/ will help you open ports on your specific model of router if your not positive, it has pages specific to different programs/games, but is a good indication of what you should be doing
You can just call me Chris

I found out I was Marilyn Monroe in a previous life





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users