I have select() that works with two sockets, socketA and socketB.
When there is data pocket on socketA the data is being processed by the subroutine that returns a value and also stores a carry value to be applied to the next data pocket from socketA the next time subroutine is called. The same goes for socketB. The problem is that everything works fine when there is only data on either socketA or socketB. When the data comes on socketB after socketA the carry value from socketA is being incorrectly applied to socketB and the return value is wrong.
Both sockets have to use the same processing subroutine and since this subroutine is very big I can not duplicate it by changing the object names. Is there a way that I could load the same subroutine twice in memory and call one from socketA and the other from socketB or perhaps I can use threads for each socket. Any help is appreciated