• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to Connect to Socket IP Using a String?

Explorer ,
Apr 15, 2015 Apr 15, 2015

Copy link to clipboard

Copied

I'm trying to make a TCP Flash game, and though I got it to work, I can't seem to get it to connect to an IP address using a string. The reason I want to do this is so that players can type in an IP address they'd want to connect to.

Here's what I have so far:

sock.connect('192.168.0.22',8080);

It works and connects to my IP address, and anyone else on the same LAN can connect to it as well, but if the server is on a DIFFERENT computer in the house, this IP would not work. That's why I want to be able to have a string to type in-game.

I tried this:

var ipaddress:String = '192.168.0.22';

sock.connect(ipaddress,8080);

But it does not work. Any ideas? Thanks in advance.

TOPICS
ActionScript

Views

581

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Apr 16, 2015 Apr 16, 2015

Something else is not working.

sock.connect('192.168.0.22',8080);


var ipaddress:String = '192.168.0.22';

sock.connect(ipaddress,8080);

Those are equivalent statements, and connect takes a string for IP - it does not matter if you define the string in the connect itself, or prior to it.

Votes

Translate

Translate
Enthusiast ,
Apr 16, 2015 Apr 16, 2015

Copy link to clipboard

Copied

Something else is not working.

sock.connect('192.168.0.22',8080);


var ipaddress:String = '192.168.0.22';

sock.connect(ipaddress,8080);

Those are equivalent statements, and connect takes a string for IP - it does not matter if you define the string in the connect itself, or prior to it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 16, 2015 Apr 16, 2015

Copy link to clipboard

Copied

LATEST

Somehow, that worked! Thank you.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines