Friday, September 9, 2011

Bangladesh Income Tax and Freelance Software Developers

In this post, I am summarizing some of the NBR documents I found regarding taxation of earnings received as inward remittance from freelance software development. (Some of the pdf documents referred use Bangla fonts).

Recently (from July 2011), some banks of Bangladesh started to deduct advanced income tax at a rate of 10% from inward remittances received by individual software developers which they receive as wage/salary. But people were able to get a full refund for the money by applying to the banks stating that this money was earned from software development.


The reason for the deduction was that in the recent amendment of Income Tax Ordinance 1984, a new section (52Q) has been added (page 14 of this pdf):

52Q. Deduction of tax from resident for any income in
connection with any service provided to any foreign person.-
Any person, responsible for paying or crediting to the account of a
resident any sum remitted from abroad by way of service charges
or consulting fees or commissions or remunerations or any other
fees called by whatever name for any service rendered or any work
done by a resident person in favour of a foreign person, shall
deduct tax at the rate of ten percent of the amount so paid at the
time of making such payment or credit of such payment to the
account of the payee .


But individual/freelance software developers who receive their earnings as remittance should be free from this tax because of the following two SROs.

SRO-216, 2005 (page 10 of this pdf):

Although it says "up to 2008", the exemption has later been extended up to 2013 with section 33 of the Sixth Schedule of Income Tax Ordinance (page 61 of this pdf):

33. Any income derived from the business of software development and Information Technology Enabled Services (ITES) for the period from the first day of July, 2008 to the thirtieth day of June, [2013]Subs. F.A. 2011:
Provided that the person shall file income tax return in accordance with the provisions of section 75(2)(c) of the Ordinance.
[Explanation : Information Technology Enabled Services (ITES) means-Digital Content Development and Management, Animation (both 2D and 3D), Geographic Information Services (GIS), IT Support and Software Maintenance Services, Web Site Services, Business Process Outsourcing, Data entry, Data Processing, Call Centre, Graphics Design (digital service), Search Engine Optimization, Web Listing, E-commerce and Online Shopping, document conversion, imaging and archiving.]Subs. F.A. 2011

This again has been extended up to 2015:

(৩) paragraph 33 সংশোধনের মাধ্যমে সফটওয়্যার উন্নয়ন ও Information Technology Enabled Services (ITES) থেকে আয় করমুক্ত থাকার মেয়াদ বৃদ্ধি করা হয়েছে। এর মাধ্যমে এ খাতের করমুক্ত আয়ের সুবিধা জুন, ২০১৫ পর্যন্ত বহাল থাকবে।
33. Any income derived from the business of software development and Information Technology Enabled Services (ITES) for the period from the first day of July, 2008 to the thirtieth day of June, [2015]Subs. F. A. 2012
Provided that the person shall file income tax return in accordance with the provisions of section 75(2)(c) of the Ordinance.

The second SRO is SRO-216, 2004 (page 2 of this pdf):



This kind of earning can be claimed as tax-free, as described in the tax-return fill-up guideline here (pages 23-25 of this pdf):





Monday, May 16, 2011

Anagram Generator

http://wordsmith.org/anagram/

Syed Andaleeb Roomy = A bad needy sly Romeo !!!

Thursday, June 10, 2010

Ambigram Generator

It's cool! Thanks to Tanim for sharing this.
Go to http://www.flipscript.com/ and hit "Create New Ambigram".




Saturday, May 8, 2010

TURN turns RFC too

Traversal Using Relays around NAT (TURN) from the IETF working group "Behave" became RFC 5766.

Friday, April 30, 2010

ICE becomes RFC 5245

Interactive Connectivity Establishment (ICE) is a protocol for Network Address Translator (NAT) traversal for offer/answer protocols. The Internet Engineering Task Force (IETF) recently approved it as RFC 5245.

Saturday, April 10, 2010

Reusing TCP Connections: "address already in use"

The socket option SO_REUSEADDR is useful for binding a socket to a port that is already in use by another socket. But even if you are successful in binding the socket, it does not mean you will not get the "address already in use" error later with that socket.

Consider a case where you want to connect from a fixed source port (srcport) and IP (srcip) to a fixed destination port (dstport) and IP (dstip) using TCP. A TCP connection is basically a 5-tuple (srcip, srcport, dstip, dstport, protocol).
The first attempt with connect() succeeds and the connection is established.
But, depending on your OS configuration, you may not be able to establish the same connection again for a while, even if you close the first connection. Even though you may succeed with SO_REUSEADDR binding the (srcip, srcport, TCP) 3-tuple, your connect() call will fail to establish the 5-tuple.

This is a very unlikely use-case because usually, clients do not need to use the same srcport in a subsequent connection. But I encountered this problem when I was developing an ICE-TCP library for a client who wanted to specify a fixed port to be used in the SDP generated by the library. In this case, there is a chance that the same fixed port will be specified for a call after the previous call ends.

This problem arises from the TIME_WAIT state of TCP.

To get around this problem, you need to "hard close" the first connection (as opposed to "graceful shutdown"). For this, set the option SO_LINGER to the socket of the first connection, with a linger timeout of zero. Then when you want to close the connection, DO NOT call shutdown(). Call only closesocket(). If you call shutdown(), a graceful shutdown is initiated with the [FIN, ACK, FIN, ACK] sequence, which ultimately leads to the stuck TIME_WAIT state.

So, in summary, if you desparately need to reuse a TCP connection 5-tuple and want to avoid the "address already in use" problem, use SO_REUSEADDR, SO_LINGER and closesocket(), and avoid shutdown().

To know more about the TIME_WAIT state and other details, check out the following links:
http://www.developerweb.net/forum/showthread.php?t=2941
http://hea-www.harvard.edu/~fine/Tech/addrinuse.html

Sunday, April 4, 2010

Reusing Ports: Socket Option SO_REUSEADDR

Recently, I came across a situation where I had to bind the same port to multiple sockets. I am just going to write some brief notes about this.

Is it possible to bind multiple sockets to the same port?
Yes, it is possible.

How?
There is a socket option for this, called SO_REUSEADDR.

Why would someone want to reuse a port?
This option is sometimes needed. For example,
  1. Suppose you have restriction on the number of ports you can use. Then you may want to use the same port for connecting to different destinations.
  2. The original use case for this option occurs when a socket is closed. It may "linger" for a while, because there is still unsent data in the buffer. So you cannot use (bind to) that port right away after the socket is closed. So you can set SO_REUSEADDR on that socket, if you think the port needs to be usable right away after closing a previously bound socket.

Can I prevent a port from being reused or hijacked?
Yes, you can.
In Linux, if you do not set SO_REUSEADDR on a socket, the port bound to that socket cannot be rebound by another socket.
But in Windows, even if you do not set SO_REUSEADDR, that port can be bound to another socket if the second socket sets SO_REUSEADDR before bind!
In order to prevent this, Windows provides another option called SO_EXCLUSIVEADDRUSE. When this option is set on a socket, the port bound to that socket cannot be reused by another socket.

Example problem
I would like to bind any free port to socket S1. Then I would like to bind that specific port to socket S2 as well.

Solution
  1. Bind any free port to S1 (specifying zero for port does this).
  2. Set socket option SO_REUSEADDR to S1 (Do not set this before binding, so that an unused port is guaranteed to be bound to S1 in step 1).
  3. Find out the port number P that is bound to S1 (getsockname can be used for this).
  4. Set socket option SO_REUSEADDR to S2 (Some OS may not need this step. But it does not do any harm to do it anyway).
  5. Bind the specific port P to socket S2.