Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
Ethmaster

Abbreviating Addresses

Question

Hello guys,

 

I saw on the wiki that we could abbreviate addresses, and I was wondering how that was done.

 

I just finished writing a simple program that uses wireless network cards and access points to fire off text messages, which the other computer receives when it uses the listening program I also built, however it requires me to type in the full address of the modem of the receiving computer, and I was wondering if there was a way to shorten that address, or give it a second address that the modem would respond to, to make things a little easier.

 

I saw on the network floppy there's ifconfig, and that has a bind command to it, but would that make the modem respond to that new, given address if sent over the wireless network?

Here's the code to the message program, if it helps at all. Thanks!

local component = require("component")
local computer = require("computer")
 
if not component.isAvailable("modem") then
 io.stderr:write("A modem is required to use this program, preferably from a wireless network card.")
 return
end
 
if not component.isAvailable("access_point") then
 io.stderr:write("An access point is required to use this program. It allows for great wireless transmissions")
 return
end
 
local ap = component.access_point
local m = component.modem
 
if not m.isWireless() then
 print("Sorry, this program only really does anything useful if you have a wireless network card installed")
 return
end
 
print("Please type in the address of your recipient: ")
local addr = io.read()
 
print("Please type in the port you wish to send this message along to: ")
local strport = io.read()
 
print("Now, please type the message you wish to transmit")
local message = io.read()
 
print("Finally, type the distance the message must cross (always be liberal when guessing distance): ")
local rangestr = io.read()
 
print("\n\nInformation added in, configuring message parameters...")
local portnum = tonumber(strport)
local rangenum = tonumber(rangestr)
 
print("Configured. Now setting ranges...")
m.setStrength(rangenum)
ap.setStrength(rangenum)
 
print("Ranges configured. Set to: "..rangenum)
print("Inputs compiled. Finalizing transmission...")
m.open(portnum)
 
if m.isOpen(portnum) then
 print("Data port is opened, proceeding with message transmission...")
 if  m.send(addr, portnum, message) then
  print("Message sent! Please ensure receipt of message!")
  return
 else
  print("Message not sent! Communications failure!")
  return
 end
else
 print("Communications failure! Unknown reason!")
end
Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

I have been able to get the full addresses using the components program and writing it down, however, my trouble was with finding the abbreviated address that's used. I was hoping to let the user add in those, then the message program would be able to use the abbreviated address of the destination modem to send it there, without having to give everyone the full address, to make things a bit easier. Any ideas on where I can find the abbreviated address?

Link to post
Share on other sites
  • 0

About the network floppy - it works over wireless networks, but is in a way broken when you move between different access points(i.e. physical nodes aren't auto-discovered for now). Also the network has dedicated API - use `man network`. Sending data to custom bound addresses via bare components won't work.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.