Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Programmers' lounge. (Programming-related discussions only)
New Posts  All Forums:Forum Nav:

Programmers' lounge. (Programming-related discussions only) - Page 113

post #1121 of 1129
Quote:
Originally Posted by alcal View Post

Ok thanks for the clarification. You'll probably want to set it up so that your when your listener connects and sets up the connection, you spawn a new listener in another thread to handle the subsequent connection. You can't talk to more than one device on a single connection (as you stated) so you'll need to always have a listener ready to offer a new connection to each device.

Once you do that, you'll have some sort of threadpool of active connections, and I think that what I said earlier about identifying them however you want should work fine. Depending on how you have things set up/what you're doing, you might want to use a thread-safe data structure of some sort to pass information between threads, though Android has policies against blocking operations in the main thread (which most thread safe data structures need to be able to do to ensure that they are indeed thread safe) so I'm not 100% sure what your options are there.

When I did some googling, I came across using hashtable to make identifier for each connections, someone else also mentioned GUID. I mean easier said than do when you say "identifying them however you want" I mean someone mentioned using device ID + timestamp but how would I implement that into the socket?

would it be something like...

socket.getoutputstream(randomgenerateID);
? idk
Collecting Dust
(13 items)
 
Server
(9 items)
 
 
CPUMotherboardGraphicsRAM
E8400 3.0ghz OC @ 3.8GHz @ 1.36v DFI BLood Iron P35 none OCZ 2x 2gb DDR2 800 CAS @ 5-6-6-21 
Hard DriveOptical DriveOSMonitor
none none loonix ssh is my monitor 
KeyboardPowerCaseMouse
none Corsair 650 watts old pc case Logitech mx518 
Mouse Pad
none! 
CPUMotherboardGraphicsRAM
AMD Athlon 64 X2 Dual Core Processor 6000+ GX611AA-ABA m8300f onboard 1x 2GB OCZ RAM DDR 
Hard DriveOSMonitorPower
320gb + 1TB HDD xubuntu 14.04 SSH 350 watt 
Case
crappy HP case 
  hide details  
Reply
Collecting Dust
(13 items)
 
Server
(9 items)
 
 
CPUMotherboardGraphicsRAM
E8400 3.0ghz OC @ 3.8GHz @ 1.36v DFI BLood Iron P35 none OCZ 2x 2gb DDR2 800 CAS @ 5-6-6-21 
Hard DriveOptical DriveOSMonitor
none none loonix ssh is my monitor 
KeyboardPowerCaseMouse
none Corsair 650 watts old pc case Logitech mx518 
Mouse Pad
none! 
CPUMotherboardGraphicsRAM
AMD Athlon 64 X2 Dual Core Processor 6000+ GX611AA-ABA m8300f onboard 1x 2GB OCZ RAM DDR 
Hard DriveOSMonitorPower
320gb + 1TB HDD xubuntu 14.04 SSH 350 watt 
Case
crappy HP case 
  hide details  
Reply
post #1122 of 1129
Quote:
Originally Posted by andyroo89 View Post

When I did some googling, I came across using hashtable to make identifier for each connections, someone else also mentioned GUID. I mean easier said than do when you say "identifying them however you want" I mean someone mentioned using device ID + timestamp but how would I implement that into the socket?

would it be something like...

socket.getoutputstream(randomgenerateID);
? idk

um socket.getOutputStream() takes no parameters as I recall so that wouldn't be possible. There is probably a better way to do this, but here is what I might do:
On initial connection:
Server generates a random ID for new device. It tells the device its ID over the connection (i.e. you write a message to the outputstrem from the server to the device informing the device of its ID).

On subsequent connections:
Device sends a message (again by writing to the outputstream of its socket) to the server saying effectively "Hi, I'm device ########"

You will need to design a simple handshake procedure for this, and possibly something resembling a protocol for the rest of the communications between client and server. Pretty much all talking between devices will be done by writing a specially formatted message to the outputstream, waiting for a reply and then responding depending on what the reply contains. None of this has to do with the socket object itself once the connection is established.

Edit: once again, how you actually name the devices doesn't really matter so long as you are sure it will avoid collisions. You could use random numbers assigned by the server, and then make sure you aren't reusing them by linearly searching a list of used numbers [this is obviously easy to implement] or you could use GUIDs or timestamps or whatever else you think suits the needs of your app.

Edit 2: if security is a concern, most of this advice is terrible and you'll have a whole new set of problems.
Edited by alcal - 8/3/15 at 7:08pm
Fractal Fury
(9 items)
 
TJ08-e Reborn!
(12 items)
 
CPUMotherboardGraphicsRAM
i7-5930k ASRock X99m Killer AMD Radeon Fury X G-Skill Ripjaws 4 32Gb 
Hard DriveCoolingKeyboardPower
Kingston Hyper-X Predator M.2 Corsair H100i GTX Ducky Shine III (MX Blue) EVGA Supernova 750 G2 
Case
Fractal Node 804 
  hide details  
Reply
Fractal Fury
(9 items)
 
TJ08-e Reborn!
(12 items)
 
CPUMotherboardGraphicsRAM
i7-5930k ASRock X99m Killer AMD Radeon Fury X G-Skill Ripjaws 4 32Gb 
Hard DriveCoolingKeyboardPower
Kingston Hyper-X Predator M.2 Corsair H100i GTX Ducky Shine III (MX Blue) EVGA Supernova 750 G2 
Case
Fractal Node 804 
  hide details  
Reply
post #1123 of 1129
Quote:
Originally Posted by alcal View Post

um socket.getOutputStream() takes no parameters as I recall so that wouldn't be possible. There is probably a better way to do this, but here is what I might do:
On initial connection:
Server generates a random ID for new device. It tells the device its ID over the connection (i.e. you write a message to the outputstrem from the server to the device informing the device of its ID).

On subsequent connections:
Device sends a message (again by writing to the outputstream of its socket) to the server saying effectively "Hi, I'm device ########"

You will need to design a simple handshake procedure for this, and possibly something resembling a protocol for the rest of the communications between client and server. Pretty much all talking between devices will be done by writing a specially formatted message to the outputstream, waiting for a reply and then responding depending on what the reply contains. None of this has to do with the socket object itself once the connection is established.

Edit: once again, how you actually name the devices doesn't really matter so long as you are sure it will avoid collisions. You could use random numbers assigned by the server, and then make sure you aren't reusing them by linearly searching a list of used numbers [this is obviously easy to implement] or you could use GUIDs or timestamps or whatever else you think suits the needs of your app.

Edit 2: if security is a concern, most of this advice is terrible and you'll have a whole new set of problems.

I figured it didn't. hmm idk this may take a couple of days/weeks to do since I am still trying to figure this out.
Collecting Dust
(13 items)
 
Server
(9 items)
 
 
CPUMotherboardGraphicsRAM
E8400 3.0ghz OC @ 3.8GHz @ 1.36v DFI BLood Iron P35 none OCZ 2x 2gb DDR2 800 CAS @ 5-6-6-21 
Hard DriveOptical DriveOSMonitor
none none loonix ssh is my monitor 
KeyboardPowerCaseMouse
none Corsair 650 watts old pc case Logitech mx518 
Mouse Pad
none! 
CPUMotherboardGraphicsRAM
AMD Athlon 64 X2 Dual Core Processor 6000+ GX611AA-ABA m8300f onboard 1x 2GB OCZ RAM DDR 
Hard DriveOSMonitorPower
320gb + 1TB HDD xubuntu 14.04 SSH 350 watt 
Case
crappy HP case 
  hide details  
Reply
Collecting Dust
(13 items)
 
Server
(9 items)
 
 
CPUMotherboardGraphicsRAM
E8400 3.0ghz OC @ 3.8GHz @ 1.36v DFI BLood Iron P35 none OCZ 2x 2gb DDR2 800 CAS @ 5-6-6-21 
Hard DriveOptical DriveOSMonitor
none none loonix ssh is my monitor 
KeyboardPowerCaseMouse
none Corsair 650 watts old pc case Logitech mx518 
Mouse Pad
none! 
CPUMotherboardGraphicsRAM
AMD Athlon 64 X2 Dual Core Processor 6000+ GX611AA-ABA m8300f onboard 1x 2GB OCZ RAM DDR 
Hard DriveOSMonitorPower
320gb + 1TB HDD xubuntu 14.04 SSH 350 watt 
Case
crappy HP case 
  hide details  
Reply
post #1124 of 1129
Quote:
Originally Posted by andyroo89 View Post

I figured it didn't. hmm idk this may take a couple of days/weeks to do since I am still trying to figure this out.

I'm still somewhat new to Android myself and am always looking to learn, so if you want to talk about something in more detail /want me to actually research my suggestions before I make them, feel free to PM me. In principle though, this shouldn't be too difficult. You just need to come up with a simple, clear way to format messages and write yourself a document establishing the protocol so you can follow it clearly when writing the client and serverside implementations.

Anyways, yeah feel free to PM me as you work through it.
Fractal Fury
(9 items)
 
TJ08-e Reborn!
(12 items)
 
CPUMotherboardGraphicsRAM
i7-5930k ASRock X99m Killer AMD Radeon Fury X G-Skill Ripjaws 4 32Gb 
Hard DriveCoolingKeyboardPower
Kingston Hyper-X Predator M.2 Corsair H100i GTX Ducky Shine III (MX Blue) EVGA Supernova 750 G2 
Case
Fractal Node 804 
  hide details  
Reply
Fractal Fury
(9 items)
 
TJ08-e Reborn!
(12 items)
 
CPUMotherboardGraphicsRAM
i7-5930k ASRock X99m Killer AMD Radeon Fury X G-Skill Ripjaws 4 32Gb 
Hard DriveCoolingKeyboardPower
Kingston Hyper-X Predator M.2 Corsair H100i GTX Ducky Shine III (MX Blue) EVGA Supernova 750 G2 
Case
Fractal Node 804 
  hide details  
Reply
post #1125 of 1129
Is there any logic in moving from VB to C# outside of platform support for C# being much greater? Is one more prevalent than the other? etc...

I ask because I was thinking of creating a few apps to make my life at work easier since I can't find anything that does what I am looking for and since I only know VB well enough to do it was going to use that. But when I saw the Android & iOS support for C# I thought it may be beneficial to use it despite having to learn it from the ground up.
Ever Evolving
(18 items)
 
   
CPUMotherboardGraphicsRAM
Phenom II 1090T Black Edition Gigabyte GA-890FXA-UD5 Diamond R9 280X Crucial Ballistix Sport 16GB VLP DDR3 1600 CL9 ... 
Hard DriveHard DriveHard DriveOptical Drive
Vertex 3 120GB SSD  2x WD 1TB Caviar Black SATA3 WD Caviar Black 640GB SATA2 HP DVD-RW 1170i 
CoolingCoolingCoolingOS
Prolimatech Megahalem 2x Delta AFB1212SHE  7x Cooler Master SickleFlow R4 fans Windows 7 Professional 64bit 
MonitorKeyboardPowerCase
2x Samsung SyncMaster E2420 23.6" 1920x1080 Logitech G15 Corsair HX1000W Cooler Master HAF932 (Fan Mod) 
MouseMouse Pad
Logitech G400 Generic 
CPUMotherboardGraphicsRAM
3.0GHz P4 w/HT Asus P5GDC-V deluxe ATI HD 3450 2GB DDR400 
Hard DriveOptical DriveOSMonitor
1x WD 360GB 1x WD 120GB 3xDead LiteOn DVDROM LiteON DVDRW XP SP3 x86 AG Neovo 17" (Sceptre 21" 1080p died) 
PowerCaseMouse Pad
Ultra 550W oldschool MGE case what mouse pad? 
  hide details  
Reply
Ever Evolving
(18 items)
 
   
CPUMotherboardGraphicsRAM
Phenom II 1090T Black Edition Gigabyte GA-890FXA-UD5 Diamond R9 280X Crucial Ballistix Sport 16GB VLP DDR3 1600 CL9 ... 
Hard DriveHard DriveHard DriveOptical Drive
Vertex 3 120GB SSD  2x WD 1TB Caviar Black SATA3 WD Caviar Black 640GB SATA2 HP DVD-RW 1170i 
CoolingCoolingCoolingOS
Prolimatech Megahalem 2x Delta AFB1212SHE  7x Cooler Master SickleFlow R4 fans Windows 7 Professional 64bit 
MonitorKeyboardPowerCase
2x Samsung SyncMaster E2420 23.6" 1920x1080 Logitech G15 Corsair HX1000W Cooler Master HAF932 (Fan Mod) 
MouseMouse Pad
Logitech G400 Generic 
CPUMotherboardGraphicsRAM
3.0GHz P4 w/HT Asus P5GDC-V deluxe ATI HD 3450 2GB DDR400 
Hard DriveOptical DriveOSMonitor
1x WD 360GB 1x WD 120GB 3xDead LiteOn DVDROM LiteON DVDRW XP SP3 x86 AG Neovo 17" (Sceptre 21" 1080p died) 
PowerCaseMouse Pad
Ultra 550W oldschool MGE case what mouse pad? 
  hide details  
Reply
post #1126 of 1129
I know im late to the party but my main language is Java but i will have to get into Delphi possibly for A level compsci, for my IDE i use NetBeans8.2 or Eclipse. At the moment I am working on a project for a GCSE qualification. Im slightly struggling with a problem with it. Using file handling i have created a text file containing multiple lines split by a straight line. I need to sort the data in a seperate program. the aim is to sort the first part of each line (name) by alphabetical order, then the second part of the data (score) by score amount ascending / descending. Im hoping to use the split function to split the lines on the center line. This then provides me with two strings i need to sort. Can i then sort these strings maybe in arrays? long and convuloted i know but any help appreciated
post #1127 of 1129
Hello everyone, what is the best way to learn how to code in MSDOS?
post #1128 of 1129
Quote:
Originally Posted by alltheGHz View Post

Hello everyone, what is the best way to learn how to code in MSDOS?

You can get this book for the basics
http://www.amazon.com/DOS-Dummies-Dan-Gookin/dp/0764503618?SubscriptionId=1ECM10QMJC4BZXXP0W02&tag=bimecom2-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=0764503618

but msdos is really dead...have you considered pascal?

also have a look at this

http://aetos.it.teithe.gr/~vassik/downloads/cn/LearningMSDOS.pdf
Main Desktop
(17 items)
 
Nitro
(6 items)
 
Red Panther
(15 items)
 
CPUMotherboardGraphicsRAM
Intel Core 2 Duo E7500 MSI P41T C31 Sapphire 6870  4GB DDR2 
Hard DriveHard DriveOptical DriveCooling
WD 500GB Samsung 840 LG 3x 140mm fans in front 1x 200mm on top 1x 120mm... 
OSMonitorMonitorKeyboard
Windows 8 Pro Syncmaster Syncmaster Razer Arctosa 
PowerCaseMouseAudio
Superflower 650watt Fractal XL Cobra e-blue Logitech Z506 
Other
USB 3.0 
CPUMotherboardGraphicsRAM
i7-4710HQ Acer GTX 860m 8 GB 
Hard DriveHard Drive
WD Blue Kingston SSD 
CPUMotherboardGraphicsRAM
AMD FX 8350 Black Edition @ 4.22Ghz ASUS CROSSHAIR V FORMULA Z Sapphire 7870 Flex GHz edition G Skill TridentX 16GB @2133Mhz 
Hard DriveHard DriveHard DriveHard Drive
Seagate Barracuda 7200rpm (RAID 1) Seagate Barracuda 7200rpm (RAID 1) Samsung 840 PRO (RAID 0) Samsung 840 PRO (RAID 0) 
Optical DriveCoolingOSMonitor
Pioneer Bluray Reader/Writer 2x NZXT NS-F200 Fans Windows 8 Pro LG 27" FULL HD 
MonitorPowerCase
Samsung MultiTouch 22" FULL HD Zalman ZM750-XG Gold NZXT 820 
  hide details  
Reply
Main Desktop
(17 items)
 
Nitro
(6 items)
 
Red Panther
(15 items)
 
CPUMotherboardGraphicsRAM
Intel Core 2 Duo E7500 MSI P41T C31 Sapphire 6870  4GB DDR2 
Hard DriveHard DriveOptical DriveCooling
WD 500GB Samsung 840 LG 3x 140mm fans in front 1x 200mm on top 1x 120mm... 
OSMonitorMonitorKeyboard
Windows 8 Pro Syncmaster Syncmaster Razer Arctosa 
PowerCaseMouseAudio
Superflower 650watt Fractal XL Cobra e-blue Logitech Z506 
Other
USB 3.0 
CPUMotherboardGraphicsRAM
i7-4710HQ Acer GTX 860m 8 GB 
Hard DriveHard Drive
WD Blue Kingston SSD 
CPUMotherboardGraphicsRAM
AMD FX 8350 Black Edition @ 4.22Ghz ASUS CROSSHAIR V FORMULA Z Sapphire 7870 Flex GHz edition G Skill TridentX 16GB @2133Mhz 
Hard DriveHard DriveHard DriveHard Drive
Seagate Barracuda 7200rpm (RAID 1) Seagate Barracuda 7200rpm (RAID 1) Samsung 840 PRO (RAID 0) Samsung 840 PRO (RAID 0) 
Optical DriveCoolingOSMonitor
Pioneer Bluray Reader/Writer 2x NZXT NS-F200 Fans Windows 8 Pro LG 27" FULL HD 
MonitorPowerCase
Samsung MultiTouch 22" FULL HD Zalman ZM750-XG Gold NZXT 820 
  hide details  
Reply
post #1129 of 1129
Quote:
I'll check out pascal, thank you!
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Programmers' lounge. (Programming-related discussions only)