I'm aware that if two Android phones are connected to a same wifi network, they can implement socket programming to transfer data between them But I actually want to know if you can use wifi as a transfer medium between two Android phones, just like you Bluetooth?
With Android 2.2+ it is possible to create a WiFi hot-spot on one device so another device can connect. Internet connection on either device is not required.
What you are looking for is ad-hoc wireless networking, which is not well supported on the Android platform. (but some people have bravely rooted their phones and enabled the functionality)
As an alternative, some builds of Android (rooted or not) will support WiFi hotspot functionality. Not all carriers will enable this.
You can try to use ad-hoc networking on one phone (which has to be Android 2.2.+) to create a Wi-Fi hotspot and connect with the second phone to that. I'm not sure if theres an API yet, I believe not. This question may help, altough it's not recommmend (See the comments in that question).
For faster transmission of data over wifi can be done by using "WifiDirect"
which is a "p2p" connection. so that this will transfer the data from
one to other device without an Intermediate(Socket). For Example catch
this link in google developers wifip2p and P2P Connection with Wi-Fi
Catch a sample in Github WifiDirectFileTransfer
来源:https://stackoverflow.com/questions/6720899/can-i-use-wifi-to-transfer-data-messages-between-two-android-phones-not-connect